-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate 3 filters and many-to-one
PostPosted: Mon May 23, 2005 5:34 am 
Newbie

Joined: Mon May 23, 2005 4:23 am
Posts: 4
Hello!

Does Hibernate 3 support filter for many-to-one associations?

I wish to make security subsystem which grant access for partners. Each partner can have products. If user has access to partner it must has access to all his products.

Can the task be solved via filters (I know how to solve this via HQL etc.?).

Hope for any advice.


Hibernate version:3.0.4

Mapping documents:
<class name="package.Product" table="product">
<id name="uuid" type="string" access="field">
<column name="uuid" sql-type="char(32)" not-null="true"/> <generator class="assigned"/></id>
<many-to-one name="partner" access="field" class="package.Partner" outer-join="false">
<column name="partner_uuid" sql-type="char(32)" not-null="true"/>
</many-to-one>
</class>
<class name="package.Partner" table="partner">
<id name="uuid" type="string" access="field" >
<column name="uuid" sql-type="char(32)" not-null="true"/><generator class="assigned"/></id>
<many-to-one name="responsibleEmployee" access="field" class="package.User">
<column name="resp_employee" sql-type="char(32)"/>
</many-to-one>
<filter name="filter" condition="resp_employee =:f"/>
</class>
<filter-def name="filter">
<filter-param name="f" type="string"/>
</filter-def>

Code between sessionFactory.openSession() and session.close():
s.enableFilter("filter").setParameter("f", "XXX");

List persons = s.createCriteria(Partner.class).list();
logger.warn("Number of persons:" + persons.size());

List products = s.createCriteria(Product.class).list();
logger.warn("Number of products:" + products.size());

Name and version of the database you are using:
MSSQL 2000

The generated SQL (show_sql=true):
select ... from partner this_ where this_.resp_employee =?

select ... from product this_ inner join luser user2_ on this_1_.responsible_uuid=user2_.uuid


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

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.