-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problem with Criteria.list() returning duplicates
PostPosted: Fri Feb 24, 2012 7:23 pm 
Newbie

Joined: Fri Feb 24, 2012 7:19 pm
Posts: 1
Criteria is returning duplicate rows. When I execute the hibernate generated query in DB then it returns different rows. Here are the details :

Mapping xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<!-- Generated Feb 16, 2012 11:42:13 AM by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
<class name="com.xxxx.xxx.xxx.xxx.xx.xxxx.dataobjects.ETLTableKeysDO" table="ETL_TABLE_KEYS">
<id name="dbName" type="java.lang.String" access="field">
<column name="DB_NAME" />
<generator class="assigned" />
</id>
<property name="tableName" type="java.lang.String" access="field">
<column name="TABLE_NAME" />
</property>
<property name="busObjKeyColumnName" type="java.lang.String" access="field">
<column name="BUS_OBJ_KEY_COLUMN_NAME" />
</property>
<property name="srcKeyColumnName" type="java.lang.String" access="field">
<column name="SRC_KEY_COLUMN_NAME" />
</property>
<property name="busObjSrcKeyColumnName" type="java.lang.String" access="field">
<column name="BUS_OBJ_SRC_KEY_COLUMN_NAME" />
</property>
<property name="srcColumnDataTypeChange" type="java.lang.String" access="field">
<column name="SRC_COLUMN_DATA_TYPE_CHANGE" />
</property>
<property name="processSK" type="long" access="field">
<column name="PROCESS_SK" />
</property>
<property name="keyColumnName" type="java.lang.String" access="field">
<column name="KEY_COLUMN_NAME" />
</property>
</class>
</hibernate-mapping>



GET Method :

public List getETLTableKeysDOList(String dbName,String tableName)
{
Session metadataSession = HibernateUtil.getMetadataSessionFactory().openSession();
//Create criteria for the required class
Criteria criteria = metadataSession.createCriteria(ETLTableKeysDO.class);
Transaction transaction = null;
List resultList = null;
try {
//Add the required search property to criteria
criteria.add(Restrictions.eq("dbName", dbName).ignoreCase());
criteria.add(Restrictions.eq("tableName", tableName).ignoreCase());

transaction = metadataSession.beginTransaction();
resultList = criteria.list();
transaction.commit();
}
catch (HibernateException e ) {
EDWLogger.error(e.getMessage(),e,null);
transaction.rollback();
}
finally {

metadataSession.close();
}

return resultList;

}

How to fix this issue ?


Top
 Profile  
 
 Post subject: Re: Problem with Criteria.list() returning duplicates
PostPosted: Mon Feb 27, 2012 4:01 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
When I execute the hibernate generated query in DB then it ...


Can you please report here the hibernate generated query?
Which version of Hiberante are you using?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

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.