[hibernate-issues] [Hibernate-JIRA] Created: (ANN-573) Many-to-many with Attributes (Attribute-class with two @ManyToOne mappings as @Id) not possible

Christian Köberl (JIRA) noreply at atlassian.com
Sat Mar 10 12:09:08 EST 2007


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
        Type: Bug

  Components: binder  
    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:
   http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira





More information about the hibernate-issues mailing list