Hi,
I'm trying to use hibernate filters to filter data per user. Using this mapping file:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<class
name="MyClass"
table="MyTable"
lazy="true"
>
<id
name="idMyTable"
type="java.lang.Integer"
column="idMyTable"
>
<generator class="native" />
</id>
<!-- Associations -->
<many-to-one
name="serviceInstance"
class="ServiceInstance"
not-null="true"
>
<column name="idServiceInstance" />
</many-to-one>
<filter name="myClients" condition="(serviceInstance.idClient IN (:clients))"/>
</class>
<filter-def name="myClients">
<filter-param name="clients" type="int"/>
</filter-def>
</hibernate-mapping>
I then use this code:
Code:
session.enableFilter("myClients").setParameterList("clients", user.getAllowedClients());
When I try to run a query, it replies something like:
Code:
Unknown column 'serviceInstance.idClient' in 'where clause'"
Shouldn't hibernate make the join? How can I do this?
Regards,
Gustavo Ambrozio