We created our own hibernate type which is defined as a Type.Varbinary.
In the pojo we define the column lenght (size = 16 ).
In that same pojo the attribute is also used to create a unique index.
Works fine with sqlserver, hsql and oracle 10G. In mysql 5.1 however, I get a nasty error
Reason: java.lang.RuntimeException: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: BLOB/TEXT column 'PREFIX' used in key specification without a key length
create table MY_TEST_TABLE (id bigint not null, attr-3 tinyblob not null, attr-2 integer not null, attr-1 bigint not null, primary key (id), unique (attr-1, attr-2, attr-3(16)))
create table MY_TEST_TABLE (id bigint not null, attr-3 tinyblob not null, attr-2 integer not null, attr-1 bigint not null, primary key (id), unique (attr-1, attr-2, attr-3))