-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: UsertType with a custom class inside
PostPosted: Tue Aug 08, 2006 7:07 pm 
Newbie

Joined: Sun Apr 09, 2006 4:57 pm
Posts: 10
Location: Milan (Italy)
I need a suggestion about an UserType problem.

I have a Quantity class with two fields: quantity(BigDecimal) and unitofmeasure (Unit, a custom class).

Using an UserType I can get the Unit id (i.e. kg,mm,meter, etc) as a String and write and read it into the database. But when I read it I should rebuild the real Unit entity and set the property of the Quantity class, as if it was a many-to-one relationship. And I expect that it is done inside the UserType implementation, as the Quantity object returned should be immediatly usable by the client code.

Unfortunatly I did non find any example about how I can read another table inside an UserType nullSafeGet() method.

Anybody can help me?
Thanks
Marco Pancotti
Italy


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 08, 2006 10:52 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
If the contents of the Unit table are basically static, you can implement this as a string-valued enum (http://www.hibernate.org/273.html). Otherwise, it's a many-to-one association.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.