Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate filter in join

 
Baisakhi Roy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Spring with Hibernate.
I have implemented hibernate filter.For simple cases it is working fine.But I am facing problem in some particular cases like for joining.
I have defined the filter defination in application-context.xml.
..........
<property name="filterDefinitions">
<list>
<bean class="org.springframework.orm.hibernate3.FilterDefinitionFactoryBean">
<property name="filterName" value="tanencyFilter" />
<property name="parameterTypes">
<props>
<prop key="tanentId">long</prop>
</props>
</property>
</bean>
</list>
</property>
.........
I have added the filter in my hbm.xml also.'

<filter name="tanencyFilter" condition=":tanentId = TANENT_ID" />

This Tanent_id is common for all the tables.

This is the query:
"select .................................................... from BedAssignment as bedAssignment right outer join bedAssignment.bed as bed "
.....................where .................";

Now if I enable the filter ,it filters the data based on bed assignment table,but I wantt to filter the data based on Bed table.Means I want to enable the filter for the Bed table not for Bed Assignment.

if any one have any idea then please help me.
 
Suddha Satwa Roy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
your code looks ok. did you use any IDE?? If not, use Eclipse or NetBeans, they will automatically configure your problem as well as xml file.
 
Baisakhi Roy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Suddha for your reply.
I am using Eclipse.
But I think you did not get my problem.
Say I have a Bed assignment table and Bed table as follows:
Bed:

BED_ID,STATUS_ID,.......,TANENT_ID

Bed_assignment:

BED_ASSIGNMENT_ID
BED_ID
PATIENT_ADMIT_ID

Now I this is the query:
select bed.bedId,bed.bedStatus...................bedAssignment.estimatedDischargeTime,................................ from BedAssignment as bedAssignment right outer join bedAssignment.bed as bed "
.....................where .................";

This is the BedAssignment class:
public class BedAssignment implements Serializable {

private static final long serialVersionUID = 1L;

private long bedAssignmentId;
private String bedId;
...........
private Bed bed;

..................
}
This is the Bed class
public class Bed implements Serializable {

private static final long serialVersionUID = 1L;
private Long tanentId;
private String bedId;
private BedStatus bedStatus;
............
}
I want that when I enable tanencyFilter ,it should enable on the Bed class not on bed_assignment.
How can I do that.Please write the code.
 
Suddha Satwa Roy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please go to the http://docs.jboss.org/hibernate/core/3.3/reference/en/html/filters.html if you send me your mail address I can send a demo that can help you.
 
Baisakhi Roy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you again for your reply.
I have already checked the link you send,but still I could not solve my problem.My mail id is emailbaisakhi@yahoo.com.You can send the demo in my mail address.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic