[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - howto persist byte[] as varbinary?

bbernie do-not-reply at jboss.com
Thu Aug 14 11:06:35 EDT 2008

I'm using Jboss 4.2.2 with Hibernate 3.2.4.sp1.  I have a few data types to persist from my entity which are of java type byte[].

Hibernate, by default, is using mysql type tinyblob for these.  How do I override this and get Hibernate to use the type varbinary instead?

After hibernate creates the database schema, I am able to change this manually by altering the tables, and everything appears to function fine, but I would prefer to have this done automatically.

Besides, if I change the hdm2ddl behavior from update to validate, hibernate will fail to validate the schema because the columns are of type varbinary instead of tinyblobs.

Any help with this would be greatly appreciated.  I've tried using the @Type annotation, but I have no idea what type I should place in there for this to work.  My database is mysql 5.0.44 with the InnoDB table engine, I am using the org.hibernate.dialect.MySQL5InnoDBDialect as my hibernate dialect.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4170594#4170594

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4170594

More information about the jboss-user mailing list