Hello,
So i want to use for my program hibernate annotations and my class should have a byte array as primary key. The key itself is not generated but set by user. I have the problem, that hibernate is mapping the byte[] as a BLOB, but i cannot assign a length. My class looks like this:
Code:
@Entity
@Table(name="room")
public class Room
{
private byte[] ID;
private String comIP;
@Id
public byte[] getID()
{
return ID;
}
public void setID(byte[] id)
{
ID = id;
}
@Column
public String getComIP()
{
return comIP;
}
public void setComIP(String comIP)
{
this.comIP = comIP;
}
}
When creating the table hibernate gives the following error:
13:43:48,640 ERROR SchemaExport:325 - Unsuccessful: create table room (id tinyblob not null, comip varchar(255), primary key (id))
13:43:48,640 ERROR SchemaExport:326 - BLOB/TEXT column 'id' used in key specification without a key length
Before i started to use hibernate annotations i fixed this problem by using the type varbinary(20), i specified this in the mapping file like this:
<id name="ID">
<column name="ID" sql-type="varbinary(20)"/>
<generator class="assigned"/>
</id>
But i really want to use annotations and i have tried to get it working for hours and hours but i couldnt find a solution. I tried to make hibernate use the varbinary type by using the @Type annotation, but it cannot find the type.
I would really appreciate if someone can help me here with this problem. I can use any solution, does not have to be by using the varbinary type.
Thanks alot!
Chris