[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2883) ManyToMany doesn't work with polymorfism

Diego Plentz (JIRA) noreply at atlassian.com
Mon Sep 29 20:05:04 EDT 2008


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

Diego Plentz commented on HHH-2883:
-----------------------------------

I think that the related issue is caused by the same bug.

> ManyToMany doesn't work with polymorfism
> ----------------------------------------
>
>                 Key: HHH-2883
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2883
>             Project: Hibernate Core
>          Issue Type: Bug
>    Affects Versions: 3.2.4
>         Environment: Hibernate 3.2.4, Annotations 3.3.0, Entitymanager 3.3.0
>            Reporter: Dirk
>         Attachments: ManyToMany-Hibernate325.zip
>
>
> We tried out the SingleTable inheritance with a ManyToMany
> @Entity
> @Table(name="SHB_PRINCIPAL")
> @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
> @DiscriminatorColumn(name="TYPE",discriminatorType=DiscriminatorType.INTEGER)
> @Cache(usage=CacheConcurrencyStrategy.TRANSACTIONAL)
> public class Principal implements Serializable {
> ....
> @Entity
> @DiscriminatorValue(PrincipalType.USER_NR)
> @Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
> public class ApplicationUser extends Principal {
> private static final long serialVersionUID = 1L;
> @ManyToMany(fetch=FetchType.LAZY, cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH},
> targetEntity=Role.class)
> @JoinTable(name="SHB_PRINCIPAL_TO_PRINCIPAL",
> joinColumns=@JoinColumn(name="FROM_PRINCIPAL_ID"),
> inverseJoinColumns=@JoinColumn(name="TO_PRINCIPAL_ID"))
> private Set<Role> roles;
> @ManyToMany(fetch=FetchType.LAZY, cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH},
> targetEntity=ApplicationGroup.class)
> @JoinTable(name="SHB_PRINCIPAL_TO_PRINCIPAL",
> joinColumns=@JoinColumn(name="FROM_PRINCIPAL_ID"),
> inverseJoinColumns=@JoinColumn(name="TO_PRINCIPAL_ID"))
> private Set<ApplicationGroup> groups;
> @Entity
> @DiscriminatorValue(PrincipalType.GROUP_NR)
> @Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
> public class ApplicationGroup extends Principal {
> private static final long serialVersionUID = 1L;
> @ManyToMany(fetch=FetchType.LAZY, cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH})
> @JoinTable(name="SHB_PRINCIPAL_TO_PRINCIPAL",
> joinColumns=@JoinColumn(name="TO_PRINCIPAL_ID"),
> inverseJoinColumns=@JoinColumn(name="FROM_PRINCIPAL_ID"))
> private Set<ApplicationUser> users;
> public ApplicationGroup() {
> super();
> this.type = PrincipalType.GROUP;
> }
> public Set<ApplicationUser> getUsers() {
> return users;
> }
> public void setUsers(Set<ApplicationUser> users) {
> this.users = users;
> }
> }
> But in the groups and the roles of the user, hibernate returns all principals, not only the users or groups. In the query it's clear that the descriminator is NOT used.

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