I have a hibernate Usertype something like this:
public class UUIDHibernateType implements UserType
{
private static final int[] SQL_TYPES = new int[] { Types.CHAR };
public int[] sqlTypes ()
{
return SQL_TYPES;
}
// ...
}
The problem I have is, that hibernate generates a sql script with the types CHAR(1) which is not correct, I would actually need CHAR(36). How would I define the default length of a custom type?
For the moment I'm stuck with defining the sql-type like this:
<id name="id"
type="org.openscada.ae.server.storage.jdbc.internal.UUIDHibernateType">
<column name="ID" length="36" sql-type="CHAR(36)" not-null="true" />
<generator class="assigned" />
</id>
It shouldn't be a problem in this case, but how would I do it if the need arises?
PS: If someone has a better idea how to handle UUIDs transparently and database agnostig, I'm grateful.