-->
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.  [ 3 posts ] 
Author Message
 Post subject: Mixed Mapping
PostPosted: Mon Dec 11, 2006 5:12 pm 
Newbie

Joined: Mon Dec 11, 2006 4:51 pm
Posts: 2
Hi All,

OK, I read the reference and the Hibernate book and probably overloaded myself. Excuse me if those references contain the answers, but I can't seem to find it.

My issue is I have a class composed of some value objects. In particular java's URL and InternetAddress classes, and am trying to figure out the best way to persist them. They lack appropriate accessor and mutator methods and I want to treat them as immutable. It seems to me they should be stored as a string in the same table as the object they belong to, and reconstituted via the contructor. I am not sure the best way to map these types of objects. One apprioach I was thinking of is to use simple helper String getter and setter that hibernate would interact with and would deal with the creation of the value object.

Any Ideas or thoughts?
Tom


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 11, 2006 5:17 pm 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
You can implement a UserType to persist this type of data. That would allow Hibernate to manage them directly. But it might be overkill if you just need to store the URL string and InternetAddress string representations. In that circumstance, your idea of having a getter and setter for the database strings create the actual URL and InternetAddress objects would work (but the Java pattern police might give you a ticket ;D ). Custom UserTypes would be the "proper" way of doing it, IMO.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 11, 2006 5:26 pm 
Newbie

Joined: Mon Dec 11, 2006 4:51 pm
Posts: 2
The Pattern Police? Hmmm... I wonder if that is like a parking ticket where you can get away with a few violation before they put a boot on your computer?

Anyways, cool, thanks for the quick response. I think I read briefly about the user types. Time to dig into it. I perfer simpler so I might go with the wrapping methods if it works, but I'll probably have another use for the Custom User Type soon enough.

Tom


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.