-->
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.  [ 1 post ] 
Author Message
 Post subject: UserType/CompositeUserType and lookups problem
PostPosted: Sun Jun 04, 2006 8:45 pm 
Beginner
Beginner

Joined: Sat Mar 04, 2006 1:07 am
Posts: 27
I have a domain object that stores a number of attributes as entities retrieved from a lookup table. This has proved tedious and has also coupled my domain model to the physical database schema too closely.

I would simply like to declare a String attribute in the domain object, for example
Code:
String relationship;  // rather than Lookup relationship;

and let the mapping retrieve and set the matching (Long) identifier from the lookup table. For example, if I want to store the value "spouse" in my domain object as a string, but the table where the domain object is persisted just has a foreign key id field (long) pointing to the lookup table, can I achieve this with a CompositeUserType?

I was going to use CompositeUserType instead of UserType as it provides the SessionImplementer in the nullSafeGet and nullSafeSet methods so that I can retrieve values from another table with the provided SessionImplementerObject. Can a UserType implementation be used as well?

If this considered a bad practice? I read on p205 of HIA that "..A custom mapping type could perform validation; it culd read and write data to and from an LDAP directory; it could even retrieve persistent objects from a different Hibernate Session for a different database. You're limited mainly by your imagination!"

It just seems that this way allows me to keep my domain objects free of "lookup" objects (or subclasses of lookups) and also easier to persist as I don't have to go to the DAO to get the Lookup object matching the row I want to store in the domain object.

Any advice would be appreciated
Thanks
Alan


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

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.