-->
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.  [ 9 posts ] 
Author Message
 Post subject: composite id problem with annotation based mapping
PostPosted: Fri Mar 17, 2006 11:26 am 
Beginner
Beginner

Joined: Wed Sep 24, 2003 11:16 am
Posts: 20
Location: Turkey
Hi,
I'm trying to use a component as the id of an persistent entity.
the parent class:

Code:
package model.association;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "CONTXT_OI_ASSOC")
public class ContextObjectItemAssociation {
    private ContextObjectItemAssociationId id;
    @Id
    public ContextObjectItemAssociationId getId() {
        return this.id;
    }
    public void setId(ContextObjectItemAssociationId id) {
        this.id = id;
    }
}


the identity class:

Code:
package model.association;

import model.context.Context;
import model.item.ObjectItem;
import commons.datamodel.CompositeId;

import javax.persistence.Embeddable;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

@Embeddable
public class ContextObjectItemAssociationId implements CompositeId {
    public ContextObjectItemAssociationId() {
    }

    public ContextObjectItemAssociationId(Context context, ObjectItem objectItem) {
        this.context = context;
        this.objectItem = objectItem;
    }

    private Context context;
    @ManyToOne
    @JoinColumn(name = "CONTXT_ID")
    public Context getContext() {
        return this.context;
    }
    public void setContext(Context context) {
        this.context = context;
    }

    private ObjectItem objectItem;
    @ManyToOne
    @JoinColumn(name = "OBJ_ITEM_ID")
    public ObjectItem getObjectItem() {
        return this.objectItem;
    }
    public void setObjectItem(ObjectItem objectItem) {
        this.objectItem = objectItem;
    }
}


but this mapping causes an exception saying "model.association.ContextObjectItemAssociationId has not persistent id property" on the session factory creating phase.

composite id classes that have primitive properties (not only association properties) are not causing this exception.

I have seen a phrase in hibernate associations reference document saying:

Quote:
You cannot use association annotations in an embeddable object (ie no @*ToOne nor @*ToMany). This is disallowed by the spec, and not yet supported in Hibernate Annotations.


what does this mean? are many-to-one associations also disallowed in composite objects?

thanks in advance,
regards,
Ahmet


Hibernate version: 3.1

Mapping documents: Annotation based mapping

Name and version of the database you are using: hsqldb

_________________
may the source be with you!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 25, 2006 8:54 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
@ManyToOne is now possible in embeddable objects (while not EJB3 compliant)

I cannot reproduce that on SVN trunk but I did some work in this area. To be released soon

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 27, 2006 3:55 am 
Beginner
Beginner

Joined: Wed Sep 24, 2003 11:16 am
Posts: 20
Location: Turkey
thanks a lot. what is the planned release version and date for this fix?

_________________
may the source be with you!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 28, 2006 5:11 am 
Beginner
Beginner

Joined: Wed Sep 24, 2003 11:16 am
Posts: 20
Location: Turkey
Emmanuel, sorry for the rush but I need the fix as soon as possible. I've been stuck on this problem since 3 days, and delving into hibernate code gives no hope. If you can send me the fix I'd be very grateful.
Thanks in advance.

_________________
may the source be with you!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 4:05 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
By the time you posted your message, the version was released. Did you look at the website?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 4:46 am 
Beginner
Beginner

Joined: Wed Sep 24, 2003 11:16 am
Posts: 20
Location: Turkey
yep, with the latest code from svn it's working all fine. thanks for such an immediate response.

_________________
may the source be with you!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 05, 2006 5:43 am 
Newbie

Joined: Tue May 25, 2004 11:20 am
Posts: 17
Location: Munich, Germany
Hi guys,

I have a very similar structure of classes. Something like ContextObjectItemAssociation that has a PrimaryKeyClass containing two @ManyToOne properties. This class is referenced by another class by @OneToMany.

After I have noticed that hibernate-annotations-3.1beta9 was release I downloaded it and realized that it depends on hibernate-3.2-cr2. I didn't find hibernate-3.2-cr2 so I tried rc1.

I'm still getting: <PrimaryKeyClass> has not persistent id property.

What's going wrong? Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 05, 2006 6:51 am 
Beginner
Beginner

Joined: Wed Sep 24, 2003 11:16 am
Posts: 20
Location: Turkey
annotations 3.1 beta9 isn't working completely. try latest from svn. the fix will be on annotations 3.1 beta10 which is not yet released.

_________________
may the source be with you!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 05, 2006 6:58 am 
Newbie

Joined: Tue May 25, 2004 11:20 am
Posts: 17
Location: Munich, Germany
thank's anarkhos. I'll give it a try.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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.