l have an DAO , it load all the borrows ,
Code:
public Collection loadAllBorrow() throws DataAccessException {
return getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
//session.disableFilter("borrowStateFilter");
Criteria criteria = session.createCriteria(Borrow.class);
return criteria.list();
}
});
}
it generated sql below,
Code:
select this_.BORROW_ID as BORROW1_8_1_, .... from school.BORROW this_ inner join school.ITEM item2_ on this_.ITEM_ID=item2_.ITEM_ID where this_.STATE in (?, ?, ?, ?, ?, ?, ?)
with the extra " this_.STATE in (?, ?, ?, ?, ?, ?, ?) " ,
this is suppose to be another query's filter parameters , so l have to diable the filter explicitly by uncomment the filter using
Quote:
session.disableFilter("borrowStateFilter");
But by the doc ,
Quote:
By default, filters are not enabled for a given session; they must be explcitly enabled through use of the Session.enabledFilter() method
am l did something wrong ?
my mapping hbm.xml ,
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 default-access="field">
<class name="org.minioasis.library.domain.Borrow" table="BORROW" catalog="school" lazy="true">
<id name="id" type="long" column="BORROW_ID" unsaved-value="null">
<generator class="native" />
</id>
<version name="version" type="int" column="VERSION" />
<property name="borrowDate"
type="date"
column="BORROW_DATE"
not-null="true" />
<property name="dueDate"
type="date"
column="DUE_DATE"
not-null="true" />
<property name="actionDate"
type="date"
column="ACTION_DATE" />
<property name="finePaidDate"
type="date"
column="FINE_PAID_DATE" />
<property name="lostOrDamagePaidDate"
type="date"
column="LOST_OR_DAMAGE_PAID_DATE" />
<property name="finePaidAmount"
type="big_decimal"
column="FINE_PAID_AMOUNT" />
<property name="lostOrDamageFineAmount"
type="big_decimal"
column="LOST_OR_DAMAGE_FINE_AMOUNT" />
<property name="renewedNo"
type="integer"
column="RENEWED_NO"
not-null="true" />
<property name="borrowState"
type="borrowState"
column="STATE"
not-null="true"/>
<many-to-one name="user"
class="org.minioasis.userinfo.domain.User"
cascade="none"
column="USER_ID"
update="false"
not-null="true" />
<many-to-one name="libraryUserType"
class="org.minioasis.library.domain.LibraryUserType"
column="LIBRARY_USER_TYPE_ID"
not-null="true" />
<many-to-one name="item"
class="org.minioasis.library.domain.Item"
fetch="join"
cascade="save-update"
column="ITEM_ID"
not-null="true" />
<filter name="borrowStateFilter" condition="STATE in (:effectiveBorrowState)" />
</class>
<filter-def name="borrowStateFilter">
<filter-param name="effectiveBorrowState" type="string" />
</filter-def>
</hibernate-mapping>
l am using hibernate-3.2.4.sp1,
moon