I'm curious if anyone has used the JScience library in conjunction with Hibernate? JScience is a great library for representing different types of units. Ideally I would like to be able to persist data objects that contain both a value (as a float) and a unit (as a JScience Unit object). Any suggestions or known reference material?
Thanks, Dave [ December 29, 2005: Message edited by: David Irwin ]
After poking around the JScience code-base and reading about Hibernate's UserType interface, I was able to create a custom UserType definition for storing JScience Units in a database. It works pretty well. I've included the class below:
You can then define an object variable in the corresponding Hibernate mapping file as follows:
There may indeed be better ways to implement this functionality. I'd love to hear people's thoughts.
Thanks, Dave [ January 05, 2006: Message edited by: David Irwin ]