-->
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: map-key ignores user specified type when writing to db
PostPosted: Fri Nov 11, 2011 4:50 am 
Newbie

Joined: Fri Nov 11, 2011 4:41 am
Posts: 1
hello everybody
I would like to ask you one question about mapping map with usertype as map-key
I have postgresql db with some tables and use inet type for storing ip adresses
Usually, hibernate does not have problem with this type and use my provided mapping (attributes like type="", write="", sql-type="" ...)
but I have problem with mapping map, where inet type should be key of this map
It seems, that the mapping for this is ignored
my mapping looks like:

Code:
<map name="macAddresses" table="EVENT_IP_MAC_LIST">
        <key column="KEY_EVENT" />
     <map-key type="cz.certicon.gwt.camnep.data.server.types.PostgresCustomType">
     <column name="IP_ADDRESS" write="inet(?)" sql-type="inet" not-null="true" />
     </map-key>
     <element type="cz.certicon.gwt.camnep.data.server.types.PostgresCustomType">
     <column name="MAC_ADDRESS" write="macaddr(?)" sql-type="macaddr" not-null="true"/>
     </element>
</map>


And when inserting to db, insert statement is generated:
Code:
Batch entry 0 /* insert collection row cz.certicon.gwt.camnep.data.server.beans.EventBean.macAddresses */ insert
into EVENT_IP_MAC_LIST (KEY_EVENT, IP_ADDRESS, MAC_ADDRESS) values ('221024', '74.125.39.147', macaddr('74:ea:3a:80:18:e4')) was aborted.  Call getNextException to see the cause.
(JDBCExceptionReporter.java:233) - SQL Error: 0, SQLState: 42804                                                                                 
(JDBCExceptionReporter.java:234) - ERROR: column "ip_address" is of type inet but expression is of type character varying


you can see, that mac address is correctly casted to macaddr type, but ip address is string

Using hibernate 3.6.8, postgres jdbc 9.0

any ideas?
thanks in advence


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