-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Workaround for filter tag in subclass ( for Hibernate 3.6 )
PostPosted: Mon Dec 07, 2015 10:03 pm 
Newbie

Joined: Mon Dec 07, 2015 10:00 pm
Posts: 1
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
……


Top
 Profile  
 
 Post subject: Re: Workaround for filter tag in subclass ( for Hibernate 3.6 )
PostPosted: Tue Dec 08, 2015 3:13 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
You can try with the @Where annotation and see if it's working for you:

http://stackoverflow.com/questions/7700071/how-to-use-where-in-jpa-hibernate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.