-->
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: Problem with DOM4J persistence and composite keys
PostPosted: Fri Jul 24, 2009 8:50 am 
Newbie

Joined: Fri Jul 24, 2009 8:42 am
Posts: 1
I have an mapped entity with a composite key as follows:

Code:
@javax.persistence.MappedSuperclass
public class BaseEntity implements Serializable
{
    @Id()
    @Columns(columns={@Column(name="mandator"),@Column(name="id")})   
    private CompositeKey id;
}


When I try to load as xml with DOM4J

Code:
Session session = hibernateSession.getSession(EntityMode.DOM4J);
Element element = (Element)session.get(BaseEntity .class, entity.getId());


I get the exception

Code:
java.lang.ClassCastException: ch.legando.data.hibernate.CompositeKey
   at org.hibernate.property.Dom4jAccessor$ElementGetter.get(Dom4jAccessor.java:215)
   at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValue(AbstractComponentTuplizer.java:87)
   at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValues(AbstractComponentTuplizer.java:93)
   at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:376)
   at org.hibernate.type.ComponentType.getHashCode(ComponentType.java:207)
   at org.hibernate.engine.EntityKey.generateHashCode(EntityKey.java:126)
   at org.hibernate.engine.EntityKey.<init>(EntityKey.java:70)
   at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:115)
   at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:905)
   at org.hibernate.impl.SessionImpl.get(SessionImpl.java:842)
   at org.hibernate.impl.SessionImpl.get(SessionImpl.java:835


It is working fine with a simple integer key!!

I am using hibernate hibernate 3.3 with hibernate annotations 3.4

Any help is much appreciated
Stefan


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.