Ryan Ricard

www topics worth sharing.

Hibernate Oracle Guid Generator

So you’re using Oracle for a Hibernate application and you have a class that requires a GUID generator, which is reasonable… according to Hibernate’s documentation you’re out of luck (http://docs.jboss.org/hibernate/core/3.5/api/org/hibernate/id/GUIDGenerator.html).

Not true! Reviewing the answers on this stackoverflow discussion, you will find just the opposite: http://stackoverflow.com/questions/846786/configure-hibernate-to-use-oracles-sys-guid-for-primary-key

I have been mapping GUID class keys using ColdFusion 9, Hibernate, and ColdMVC for almost a year now without issue.

Going against the grain, I find managing Hibernate mappings more straightforward within a .hbmxml file rather than using CFC properties. So my key mappings are coded as follows:

HBMXML
1
2
3
4
  <id name="id" type="string">
      <column name="ID"/>
      <generator class="guid"/>
  </id>

Comments