[hibernate-issues] [Hibernate-JIRA] Created: (ANN-842) Collection's @Where doesn't support @SecondaryTable columns

StarBreeze (JIRA) noreply at atlassian.com
Mon Jun 8 06:13:13 EDT 2009


Collection's @Where doesn't support @SecondaryTable columns
-----------------------------------------------------------

                 Key: ANN-842
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-842
             Project: Hibernate Annotations
          Issue Type: Bug
    Affects Versions: 3.4.0.GA
         Environment: 3.4.0.GA, MS SQL Server 2005
            Reporter: StarBreeze


@Where annotation of collection wrongly mapping columns of entity secondary tables as columns of primary table.

Example:

@Entity
@Table(name = "Object")
@SecondaryTable(name="Classifier")
public class Classifier {
    ...

    @Column(table="Classifier", name = "IsService")
    public Boolean isService() {
        return service;
    }

    public void setService(Boolean service) {
        this.service = service;
    }

    @ManyToOne
    @JoinColumn(name = "CategoryId")
    public Category getCategory() {
        return category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }
}

@Entity
@Table(name = "Category")
public class Category {
     ...

    @OneToMany(mappedBy = "category", fetch = FetchType.LAZY)
    @Where(clause="IsService <> 1")
    public List<Classifier> getClassifiers() {
        return classifiers;
    }

    public void setClassifiers(List<Classifier> classifiers) {
        this.classifiers = classifiers;
    }
}

generates SQL on fetch Category's classifiers:
select ... from Object classifier0_ inner join Classifier classifier0_1_ on classifier0_.ObjectId=classifier0_1_.ClassifierId where  ( classifier0_.IsService <> 1)

Expected SQL:
select ... from Object classifier0_ inner join Classifier classifier0_1_ on classifier0_.ObjectId=classifier0_1_.ClassifierId where  ( classifier0_1_.IsService <> 1)

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