-->
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: filter enable automatically ?
PostPosted: Mon May 28, 2007 4:06 am 
Beginner
Beginner

Joined: Mon Sep 27, 2004 11:51 pm
Posts: 22
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


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.