[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3331) SQL for a OneToMany-association does not include the target type's @Where restriction

Adrian Moos (JIRA) noreply at atlassian.com
Wed Jun 4 13:25:33 EDT 2008


SQL for a OneToMany-association does not include the target type's @Where restriction
-------------------------------------------------------------------------------------

                 Key: HHH-3331
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3331
             Project: Hibernate3
          Issue Type: Bug
            Reporter: Adrian Moos
            Priority: Minor


@Entity
class A {
    @OneToMany(mappedBy="a", targetEntity=B.class)
    Set<B> getBs();
}

@Entity
@Where(clause = "someColumn > 1")
class B {
    @ManyToOne(targetEntity = A.class, optional = false, fetch = FetchType.LAZY)
    @JoinColumns(...)
    A getA();
}

The call

session.createCriteria(A.class).createAlias("bs", "b").list();

issues an SQL-Statement missing the restriction "b.someColumn > 1".

Analysis reveals that the JoinWalker delegates to OuterJoinableAssociation, who in turn delegates to joinableType.getOnCondition(...). In my case, joinableType is an instance of AbstractCollectionPersister, whose implementation of getOnCondition(...) only checks for a where annotation on the collection mapping, but not on the target entity.

A workaround obviously is to redundantly annotate the restriction of the collection mapping as well.

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