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

Christian Köberl (JIRA) noreply at atlassian.com
Wed Jul 14 08:33:13 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=37784#action_37784 ] 

Christian Köberl commented on HHH-4226:
---------------------------------------

Verified newer versions of Hibernate, the problem occurs in all versions: 3.3, 3.4 and 3.5.1.

> Many-to-many with Attributes (Attribute-class with two @ManyToOne mappings as @Id) not possible
> -----------------------------------------------------------------------------------------------
>
>                 Key: HHH-4226
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4226
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: annotations
>         Environment: Hibernate+Annotations 3.2.1-ga, HSQLDB 1.8.0.7
>            Reporter: Christian Köberl
>         Attachments: manytomanybug.zip, manytomanybug_core_3_6.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