I am using Hibernate + JPA as my ORM solution.
I am using HSQL for unit testing and PostgreSQL as the real database.
I want to be able to use Postgres's native UUID type with Hibernate, and use the UUID in its String representation with HSQL for unit testing (since HSQL does not have a UUID type).
I am using a persistence XML with different configurations for Postgres and HSQL Unit Testing.
Here is how I have Hibernate "see" my custom UserType:
@Id
@Column(name="UUID", length=36)
@org.hibernate.annotations.Type(type="com.xxx.UUIDStringType")
public UUID getUUID() {
return uuid;
}
public void setUUID(UUID uuid) {
this.uuid = uuid;
}
and that works great. But what I need is the ability to swap out the "com.xxx.UUIDStringType" part of the annotation in XML or from a properties file that can be changed without re-compiling.
Any ideas?