-->
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: how to annotate bidirectional one-2-many w/ composite pk
PostPosted: Wed Apr 19, 2006 11:58 am 
Newbie

Joined: Fri Jan 06, 2006 3:01 pm
Posts: 2
Simple bidirectional one-to-many, order has N order lines, the pk of order line is a composite (order_id, line_item_id). I can't seem to find a way to annotate this so
that it would work. Using the latest versions of hibernate + annotations.
BTW, I've also tried mappedBy="id" and mappedBy="id.order"

Any help is appreciated,
marko



Hibernate version: 3.2
Mapping documents:

@Entity()
@Table(name="ORDERS")
class Order
{
@Id
@Column(name="ORDER_ID")
public Integer getId() { return id; }
public void setId(Integer id) { this.id = id; }

@OneToMany(mappedBy="order", cascade=CascadeType.ALL)
public Set<OrderLine> getLines() { return lines; }
public void setLines(Set<OrderLine> lines) { this.lines = lines; }
}

@Entity()
@Table(name="ORDER_LINE_ITEM")
public class OrderLine
{
@EmbeddedId
public OrderLinePk getId() { return id; }
public void setId(OrderLinePk id) { this.id = id; }
}

@Embeddable
public class OrderLinePk implements Serializable
{
@ManyToOne(fetch= FetchType.LAZY)
@JoinColumn(name="ORDER_ID")
public Order getOrder() { return order; }
public void setOrder(Order order) { this.order = order; }

@Column(name="LINE_ITEM_ID")
public Integer getLineItemId() { return lineItemId; }
public void setLineItemId(Integer lineItemId) { this.lineItemId = lineItemId; }
}



Full stack trace of any exception that occurs:

Caused by: org.hibernate.MappingException: property not found: order on OrderLine
at org.hibernate.mapping.PersistentClass.getProperty(PersistentClass.java:377)
at org.hibernate.mapping.PersistentClass.getProperty(PersistentClass.java:382)
at org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:159)
at org.hibernate.cfg.annotations.CollectionBinder.bindCollectionSecondPass(CollectionBinder.java:900)
at org.hibernate.cfg.annotations.CollectionBinder.bindOneToManySecondPass(CollectionBinder.java:491)
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:422)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:396)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:35)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1016)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:244)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1172)


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.