Filters in 3.1 don't work for me. Is it the order of my calls or the fact 'm doing 1-1 loading in a lazy fashion?
I've also noticed I can't do a named query with item.class. I get a parse error on it.
Hibernate version:
3.1
Mapping documents:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class table="item" name="org.exussum.dkpmanager.Item">
<id access="property" name="id">
<generator class="native"/>
</id>
<many-to-one not-null="true" column="pool_id" access="property" name="pool"/>
<property name="name" not-null="true" access="property"/>
</class>
<filter-def condition="unused <> true" name="item.filter.active"/>
<filter-def condition="pool.id = :poolId" name="item.filter.pool.id">
<filter-param type="integer" name="poolId"/>
</filter-def>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
Filter filter = getSession().enableFilter("item.filter.pool.id");
filter.setParameter("poolId",
item.getPool().getId());
Query query = session.getNamedQuery("query_name_in_other.hbm");
List list = query.list();
Name and version of the database you are using:
MSSQL Server 2k
The generated SQL (show_sql=true):
select item0_.id as id3_, item0_.pool_id as pool4_3_, item0_.name as name3_ from item item0_ order by item0_.name
Debug level Hibernate log excerpt: