-->
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.  [ 6 posts ] 
Author Message
 Post subject: Postgresql's inet type, ipv4/ipv6/mac
PostPosted: Tue Jan 13, 2004 10:17 am 
Beginner
Beginner

Joined: Wed Oct 29, 2003 11:52 am
Posts: 37
Location: Gothenburg, Sweden
Hi!

I've failed to find (google and this forum) a working example where Hibernate maps the postgresql type INET. Have anyone seen work being made on this anywhere, 'cause I've failed to find that as well.

The way to do it would of course be to create a new Type, but without looking much into it, that seems to be a too big a challenge to me.

So, currently, what I'm looking at is to map the bean properties as Strings and then implement Lifecycle to set up proper Java classes in onLoad, and convert them back to string in onUpdate and onSave.

Is there a better way to do this? Is there something particular I should consider regarding the Lifecycle-approach?

Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 13, 2004 10:19 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Implementing a custom UserType for this is actually very easy. This is really the way to go here.


Top
 Profile  
 
 Post subject: Forgot
PostPosted: Tue Jan 13, 2004 10:19 am 
Beginner
Beginner

Joined: Wed Oct 29, 2003 11:52 am
Posts: 37
Location: Gothenburg, Sweden
Oh, I intend to use the MACADDR type and INET, but only for IPv4Address - no ranges and no IPv6. (I hope someone else have provided a better solution when I need IPv6 support in the application.)


Top
 Profile  
 
 Post subject: UserType
PostPosted: Tue Jan 13, 2004 10:21 am 
Beginner
Beginner

Joined: Wed Oct 29, 2003 11:52 am
Posts: 37
Location: Gothenburg, Sweden
Ok, I'll give it a try then. Thanks.


Top
 Profile  
 
 Post subject: Re: Postgresql's inet type, ipv4/ipv6/mac
PostPosted: Tue Jan 13, 2004 10:22 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
fwendt wrote:
Is there something particular I should consider regarding the Lifecycle-approach?

onSave and onUpdate are actually called dring the first usage of save or update.

Code:
Object o = session.load(...);
session.update(o);

won't call onUpdate().

Consider using a custom type. There is a sample in the wiki area

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 13, 2004 12:35 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
A good sample is for example this one: http://www.hibernate.org/76.html


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