[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-4233) cant bind a child using mappedby relating to a parent attribute(polymorphism)

Darren Kelly (JIRA) noreply at atlassian.com
Mon Nov 28 00:37:21 EST 2011


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

Darren Kelly commented on HHH-4233:
-----------------------------------

I would like to confirm that this feature also works in EclipseLink (and in OpenJPA as observed above), and want to like others above make the case for support, instead of rejection, of this feature.

I disagree with Emmanuel's remarks about the described relationship being a "Frankenstein" one, and for what it is worth I am a very experienced UML expert (and even worked as an expert consultant for a UML tool vendor, and I teach advanced UML, too). There is nothing wrong at all with having a complex relationship that consists of 2 different associations, where one of the Associations references a subclass that inherits from another class, and my own code makes very good use of the fact, frequently, and it works fine with EclipseLink.

The fact that Hibernate does not support this feature is preventing me from experimenting with it as an alternative JPA provider, I would have to undertake a significant re-coding exercise just to try it out.

Please reopen this issue, and please instead of rejecting it as a resolution ask why other JPA providers manage to support this useful "Frankenstein"  tri-directional arrangement (whereby one side of the triangle is a Generalization relationship, and hence the sides of the triangle are of a different nature). Emmanuel, you are comparing Association apples with Generalization oranges. 

Dr Darren Kelly (Webel IT Australia)

> cant bind a child using mappedby relating to a parent attribute(polymorphism)
> -----------------------------------------------------------------------------
>
>                 Key: HHH-4233
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4233
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: annotations
>         Environment: osx 10.4, java 1.5
>            Reporter: Nino Martinez
>            Assignee: Emmanuel Bernard
>         Attachments: JPA101.zip
>
>
> This is pseudo class hieracy
> @Entity
> @Inheritance(strategy = InheritanceType.JOINED)
> Mammal
> {
> @ManyToOne
> Person owner;
> }
> @Entity
> Cat extends Mammal
> Person{
> @Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
> 	@OneToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE,
> 			CascadeType.REMOVE }, mappedBy = "owner")
> 	private List<Cat> cats = new ArrayList<Cat>();
> }
> it gives the error mission property:
>  javax.persistence.PersistenceException: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property:
> Cat.owner in Person.cats
> This is the related thread on hibernate forum:
> http://forum.hibernate.org/viewtopic.php?p=2380570#2380570
> I can confirm that the same example does work when using OpenJPA as a provider. Please see attached project for reference.
> Please do not hesitate me if you have questions.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list