-->
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: composite id problem with annotation based mapping
PostPosted: Fri Mar 17, 2006 11:15 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  
 
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.