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