-->
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 primary key and annotations
PostPosted: Fri Jan 06, 2006 3:10 pm 
Newbie

Joined: Fri Jan 06, 2006 3:01 pm
Posts: 2
I have a problem with my composite primary key class and annotations.
The primary key contains two many-to-one references to other tables.
I have another class like the one below that works. The difference is that
the working class has a third variable which is NOT a reference but a simple Integer variable. Does anyone have any idea how to get this
working?

Marko


Hibernate version:
3.1

Mapping documents:

@Embeddable
public class ContractLinePK implements Serializable
{
private Contract contract;
private Sku sku;

@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="CONTRACT_ID")
public Contract getContract() { return contract; }
public void setContract(Contract contract) { this.contract = contract; }

@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="SKU_ID")
public Sku getSku() { return sku; }
public void setSku(Sku sku) { this.sku = sku; }

// equals and hashcode omitted
}

Full stack trace of any exception that occurs:
org.hibernate.AnnotationException: ContractLinePK has not persistent id property
at org.hibernate.cfg.AnnotationBinder.bindId(AnnotationBinder.java:1499)
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1002)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:654)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:266)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:199)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1146)
at Main.<init>(Main.java:52)
at Main.main(Main.java:166)


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.