Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Using Hibernate & JScience together?

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All,

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 ]
 
David Irwin
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Rancher
Posts: 43024
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
David,
thanks for following up with a solution for all of us to benefit from.
 
Just the other day, I was thinking ... about this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic