Hi
I am experiencing a problem with Hibernate whereby a call to the DAO method I have inserted below returns duplicate results. The query should return five unique results, however, the returned list contains five references to the same object. We are currently using Hibernate 3.0.5. The same error occurs when I do a HQL query. Does anyone perhaps know what I am doing wrong? Any help would be appreciated!
I have inserted a copy of the Hibernate mapping file we use below the method.
public List findAfterDate(Date d, String[] batchNumbers){
Session session = HibernateUtil.currentSession();
try {
Criteria criteria = session.createCriteria(EctBatchHistory.class);
criteria.add(Expression.ge("timedate", d));
criteria.add(Expression.ne("description", "Batch(es) successfully created."));
criteria.add(Restrictions.in("batch", batchNumbers));
criteria.addOrder(Order.asc("timedate"));
List results = criteria.list();
return results;
} catch(Exception e){
e.printStackTrace();
return new ArrayList();
}
finally {
HibernateUtil.closeSession();
}
}
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.EctBatchHistory" table="hist" schema="dbo" lazy="false">
<id name="timedate" column="timedate" type="date" >
<generator class="assigned"/>
</id>
<property name="resellerId" column="reseller_id" type="integer" />
<property name="description" column="description" type="string" />
<property name="batch" column="batch_id" type="string" />
</class>
</hibernate-mapping>
Thanks!
|