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