-->
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: How to map URI
PostPosted: Fri Apr 21, 2006 5:43 pm 
Beginner
Beginner

Joined: Tue Aug 17, 2004 5:06 am
Posts: 46
Hibernate version: 3

What's the recommended way to map a property with Java type 'URI' ?

I could use a String for it and convert the value but that would be ugly. Should I use a user type for this ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 24, 2006 12:20 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Why is converting it to a string ugly? If you're planning on storing it in a single column in the DB, then there's no alternative. If you want to separate the URI into its five component parts and store then separately, then yes, use a UserType. But if you're just storing the string, then converting it to a string is perfect, and not ugly at all.

The only downside to this is that there's no way to set the contents of the URI after it has been created. So you'll have to write a method for hibernate's use everywhere you have a URI property: set<fieldname>(String uri). But you can stick with the preferred set<fieldname>(URI uri) for your API code.


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.