Search code examples
javamysqlhibernatehsqldb

Longblob alternative in Hibernate + HSQLDB


I have a column in a MySQL database defined as LONGBLOB. This is the java code used on its mapping:

@Type(type = "org.hibernate.spatial.GeometryType")
@Column(columnDefinition = "LONGBLOB")
private Point latlng;

I want now to share this definition in an HSQLDB (for in-memory testing), but unfortunately HSQLDB doesn't have the LONGBLOB type.

I know about the HSQLDB alternatives such as LONGVARBINARY, but how I can instruct Hibernate to use LONGBLOB on MySQL and LONGVARBINARY on HSQLDB?

(I can't replace the @Column with @Lob; I tried that and Hibernate uses by default a "geometry" type instead of "longblob". Changing the current MySQL mapping is not an option.)


Solution

  • XML mappings with orm.xml overwrites annotated mappings.

    So, you could include XML mapping file for this entity in /src/test/resources/ and define the proper datatype for this column.