Hi,
I want to persist the following map:
Code:
@javax.persistence.ElementCollection
@javax.persistence.MapKeyColumn(name = "MyMapKey")
@org.hibernate.annotations.Type(type = "MyUserType")
public java.util.Map<java.lang.Integer, x.y.z.AnImmutableObjectClass> getTheMap()
{
return this.theMap;
}
public void setTheMap(java.util.Map<java.lang.Integer, x.y.z.AnImmutableObjectClass> value)
{
this.theMap = value;
}
Unfortunately, the @Type-Annotation is used both for the Key and the Value of the map, so I have to do this (ugly) workaround (fix?) to avoid ClassCastExceptions on persisting:
Code:
@javax.persistence.ElementCollection
@javax.persistence.MapKeyColumn(name = "MyMapKey")
-> @org.hibernate.annotations.MapKeyType(value = @org.hibernate.annotations.Type(type = "org.hibernate.type.IntegerType")) <-
@org.hibernate.annotations.Type(type = "MyUserType")
public java.util.Map<java.lang.Integer, x.y.z.AnImmutableObjectClass> getTheMap()
{
return this.theMap;
}
public void setTheMap(java.util.Map<java.lang.Integer, x.y.z.AnImmutableObjectClass> value)
{
this.theMap = value;
}
Is this the intended behaviour?
I found a bug in jira (marked as fixed) that the @Type-Annotation should only have an effect on the map value, not on the key. But that was back in 2008, Hibernate version 3.3.0 -> 3.3.1.
http://opensource.atlassian.com/project ... se/ANN-696What is the current status on this? I found nothing in the specs/docs that stated clearly how it should work so I hoped to get something official here. :)
Thanks.