1 Reply Latest reply on Aug 16, 2008 12:51 PM by Kamil Demecki

    howto persist byte[] as varbinary?

    Brian Bernstein Newbie

      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.