Hello,
I have a query which normally should return only one row; I noticed however that in some cases it returns the same row twice.
Did anyone run into this problem? when I copy/paste the query (constructed by hibernate) and execute it elsewhere, I get only one row; using P6spy I see the same query executed twice.
I am using hibernate 2.1.2;
cache not used for this table
Thanks for any help.
Jan
-----------------------------------------
for completeness, the class CrfPerson has a child class like this
public class CrfPersonAll extends CrfPerson
{
}
which is mapped to another view like this, returning the same columns
<class
name="eu.cec.admin.epes.services.person.CrfPersonAll"
table="EPES_CRF_PERSONNES_ALL"
mutable="false" >
this code is executed with a freshly restarted weblogic 6.1 sp3
---------------- code ------------------------------------------------
// new Hibernate session, nothing done yet
String sql = "select comref from CrfPerson as comref " +
"where comref.perId = :perId";
Query query = session.createQuery(sql);
// id is 3551
query.setParameter("perId", id, Hibernate.LONG);
List persons = query.list();
Iterator i = persons.iterator();
if (persons.size() > 1 ) {
AppLogger.warn("queryById: id " + id + " The query got more then one result, taking the first result ");
while (i.hasNext()) {
CrfPerson person = (CrfPerson) i.next();
AppLogger.warn("person " + person.getDisplayNameByNom());
}
Iterator j = persons.iterator();
return (CrfPerson) j.next();
}
---------------My hibernate.cfg.xml is configured like this ------------
<property name="dialect">net.sf.hibernate.dialect.OracleDialect</property>
<property name="cache.use_query_cache">true</property>
...
<mapping resource="catalogs/CrfPersonnes.hbm.xml"/>
<mapping resource="catalogs/CrfPersonnesAll.hbm.xml"/>
...
----------------- file CrfPersonnes.hbm.xml ------------------------------------
<hibernate-mapping>
<!--
Created by Middlegen Hibernate plugin
http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class
name="eu.cec.admin.epes.services.person.CrfPerson"
table="EPES_CRF_PERSONNES"
mutable="false" >
<!-- <cache usage="read-only"/> -->
<id name="perId" type="java.lang.Long" unsaved-value="null">
<column name="PER_ID" sql-type="NUMBER" not-null="true"/>
<generator class="sequence">
<param name="sequence">epes_sequence</param>
</generator>
</id>
<property
name="noSysper"
column="NO_SYSPER"
type="java.lang.Long"
length="6"
/>
<property
name="nomUsuel"
column="NOM_USUEL"
type="java.lang.String"
length="80"
/>
<property
name="prenom"
column="PRENOM"
type="java.lang.String"
length="70"
/>
<property
name="dtNaiss"
column="DT_NAISS"
type="java.sql.Timestamp"
length="7"
/>
<property
name="sexCd"
column="SEX_CD"
type="java.lang.String"
length="2"
/>
<property
name="userId"
column="USERID"
type="java.lang.String"
length="14"
/>
<property
name="cgrCd"
column="CGR_CD"
type="java.lang.String"
length="8"
/>
<property
name="affectation"
column="AFFECTATION"
type="java.lang.String"
length="120"
/>
<property name="telNo"
column="TEL_NO"
type="java.lang.String"
length="40" />
<property name="dtDebAff1"
column="DT_DEB_AFF_1"
type="java.sql.Timestamp"/>
<property name="dtFinAff1"
column="DT_FIN_AFF_1"
type="java.sql.Timestamp"/>
<property name="tojCd1"
column="TOJ_CD_1"
type="java.lang.String"
length="10" />
<property name="lstCd1"
column="LST_CD_1"
type="java.lang.String"
length="6"/>
<property name="email"
column="EMAIL"
type="java.lang.String"
length="120"/>
</class>
</hibernate-mapping>