-->
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: Problem with cidr type in Postgres
PostPosted: Thu Jun 21, 2007 12:49 pm 
Newbie

Joined: Thu Jun 21, 2007 12:33 pm
Posts: 7
I have a class with a property ipRcja (String) , and a column in a table of my DB of type cidr (Postgres), when i try to persist the object into the data base:
...
myObject.setIpRcja("127.0.1.1/32");
...
session.saveOrUpdate(myObject);

i get the next message:

ERROR: The column «ip_rcja» is of type cidr but the expression is of type character varying
Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update

In my *.hbm.xml i have:

<property name="ipRcja" type="string">
<column name="ip_rcja">
<comment>Ip center</comment>
</column>
</property>

I also tried using the type java.net.InetAddress:
..
myObject.setIpRcja(InetAddres.getHostByName("localhost"));
//return a InetAddres Object
session.saveOrUpdate(myObject);
...
...
<property name="ipRcja" type="java.net.InetAddress">
<column name="ip_rcja">
<comment>Ip center</comment>
</column>
</property>

And i get a similar error:


ERROR: The column «ip_rcja» is of type cidr but the expression is of type byte
Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update

Please help¡¡¡ :(


Top
 Profile  
 
 Post subject: Use a user type
PostPosted: Thu Jun 21, 2007 10:18 pm 
Beginner
Beginner

Joined: Thu Jun 21, 2007 9:24 pm
Posts: 20
Location: Lansing, Michigan, USA
Your problem seems like a good reason to write a class that implements org.hibernate.usertype.UserType; see the class documentation and relevant manual section. For something simple like an Inet4Address, it should only take about 50 lines of code or so.


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.