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)
|