Hi, @Filter tag doesn’t work in Subclass (we are using Joined-Subclass hierarchy) in Hibernate 3.6. According to this Jira https://hibernate.atlassian.net/browse/HHH-2394, it’s fixed in Hibernate 4.2. we are currently on 3.6, before migrating to 4.2, I want to know is there a workaround to force hibernate to use filters in subclass?
Here is a simple Example on what i am trying to do: ------------------------------- @Entity @Table(name =”TEST_A”) @Inheritance(strategy = InheritanceType.JOINED) Class A{ @Column(name = "ID") Srting id;
@ManyToOne @JoinColumn(name = "C_ID") C c ; }
@Table(name =”TEST_B”) @FilterDef(name="test") @Filter(name="test", condition =”type = ‘abc’”) @PrimaryKeyJoinColumn(name = "ID") Class B extends A { String type; }
@Entity @Table(name = "TEST_C") Class C { @Column(name = "C_ID") String c_id; @OneToMany(mappedBy = "c") List<A> a = new ArrayList<A>(); }
Snippet from DAO ----------------------- query = select C as c left join c.a as b where type(b) = B;
Session s = getSession(); s.enableFilter("test "); s_query = s.createQuery(query); s_query.list();
Generated query in Hibernate 3.6 (I don’t see b.type = “abc” in the where clause): ------------------------------------------ select C as c left outer join A as a on c.C_ID = a.C_ID left outer join B b on b.ID = a.ID ……
|