]
Emmanuel Bernard commented on ANN-573:
--------------------------------------
Christian, I looked at your test case and it is similar to what's inside
Note that for @EmbeddedId the mappedBy should be something like "id.order"
Can you give version 3.3 a try?
Many-to-many with Attributes (Attribute-class with two @ManyToOne
mappings as @Id) not possible
-----------------------------------------------------------------------------------------------
Key: ANN-573
URL:
http://opensource.atlassian.com/projects/hibernate/browse/ANN-573
Project: Hibernate Annotations
Issue Type: Bug
Components: binder
Affects Versions: 3.2.1
Environment: Hibernate+Annotations 3.2.1-ga, HSQLDB 1.8.0.7
Reporter: Christian Köberl
Attachments: manytomanybug.zip
Im trying to map the following relation:
Order 1-n OrderLine m-1 Product
where the OrderLine contains an amount of the ordered product.
The problem seems to be multiple @Id in combination with @ManyToOne:
@Entity
@Table(name = "order_line")
// @IdClass(OrderLinePK.class)
public class OrderLine implements Serializable
{
@Id
@ManyToOne(targetEntity = Order.class)
@JoinColumn(name = "order_id", nullable = false)
private Order order;
@Id
@ManyToOne(targetEntity = Product.class)
@JoinColumn(name = "product_id", nullable = false)
...
}
Hibernate maps the OrderLine class in the following way:
DEBUG SchemaUpdate:149 - create table order_line (product varbinary(255) not null, order
varbinary(255) not null, amount integer, primary key (order))
(maybe this relates to
http://opensource.atlassian.com/projects/hibernate/browse/ANN-435)
When I add an IdClass to the OrderLine, I get the following exception:
Initial SessionFactory creation failed.org.hibernate.AnnotationException: mappedBy
reference an unknown target entity property: model.OrderLine.order in
model.Order.lineItems
The example is attached as a runnable Maven2-Project, just run mvn test. The test
dao.OrderDaoAnnotationTest fails.
In the project I also tried to map the same classes with hbm-Files and this works
(dao.OrderDaoHbmTest).
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: