-->
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.  [ 3 posts ] 
Author Message
 Post subject: More than one row with the given identifier was found
PostPosted: Tue Feb 28, 2006 3:26 am 
Beginner
Beginner

Joined: Tue Feb 15, 2005 8:14 am
Posts: 32
I get this when I try to load a Patient in the DB.
I am sure there is no more than one record with the id.

The code runs on a websphere 6.

Hibernate version:
2.1.8

Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping
>
<class
name="dk.rhos.healthcare.epr.comp.patient.spec.model.dto.patient.Patient"
table="pat_patient"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
optimistic-lock="version"
>

<id
name="id"
column="id"
type="java.lang.Long"
>
<generator class="sequence">
<param name="sequence">pat_patient_sequence</param>
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-Patient.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<property
name="canonicalRepresentationId"
type="java.lang.Long"
update="true"
insert="true"
access="property"
column="canonicalRepresentationId"
/>

<many-to-one
name="person"
class="dk.rhos.healthcare.epr.comp.patient.spec.model.dto.person.Person"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
foreign-key="patientRole"
column="personId"
not-null="true"
unique="true"
/>

<component
name="maritalStatus"
class="dk.rhos.healthcare.epr.comp.patient.spec.model.dto.patient.MaritalStatusClassification"
>

<property
name="sid"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="maritalstatus_sid"
/>

<property
name="cid"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="maritalstatus_cid"
/>

</component>

<component
name="gender"
class="dk.rhos.healthcare.epr.comp.patient.spec.model.dto.patient.GenderClassification"
>

<property
name="sid"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="gender_sid"
/>

<property
name="cid"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="gender_cid"
/>

</component>

<property
name="physician"
type="java.lang.Long"
update="true"
insert="true"
access="property"
column="physician"
/>

<property
name="deathDate"
type="java.util.Date"
update="true"
insert="true"
access="property"
column="deathDate"
not-null="false"
/>

<property
name="created"
type="java.util.Date"
update="true"
insert="true"
access="property"
column="created"
not-null="true"
/>

<property
name="createdBy"
type="java.lang.Long"
update="true"
insert="true"
access="property"
column="createdBy"
not-null="true"
/>

<property
name="updated"
type="java.util.Date"
update="true"
insert="true"
access="property"
column="updated"
not-null="true"
/>

<property
name="updatedBy"
type="java.lang.Long"
update="true"
insert="true"
access="property"
column="updatedBy"
not-null="true"
/>

<property
name="persistenceVersion"
type="java.lang.Integer"
update="true"
insert="true"
access="property"
column="persistenceVersion"
not-null="true"
/>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Patient.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>



Code between sessionFactory.openSession() and session.close():
result = (Patient) session.get(Patient.class, patientId);

Full stack trace of any exception that occurs:

net.sf.hibernate.HibernateException: More than one row with the given identifier was found: 120, for class: dk.rhos.healthcare.epr.comp.patient.spec.model.dto.patient.Patient [Wrapped in SerializableException]
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:71)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:51)
at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:413)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2131)
at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:2001)
at net.sf.hibernate.impl.SessionImpl.get(SessionImpl.java:1937)
at dk.rhos.healthcare.epr.comp.patient.impl.dao.hibernate.SessionHelperHibernate.get(SessionHelperHibernate.java:139)
at dk.rhos.healthcare.epr.comp.patient.impl.dao.hibernate.PatientDAOHibernate.getPatientById(PatientDAOHibernate.java:375)
at dk.rhos.healthcare.epr.comp.patient.impl.services.patient.command.GetPatientByIdCommand.doExecute(GetPatientByIdCommand.java:26)
at dk.rhos.healthcare.epr.comp.patient.impl.services.common.Command.execute(Command.java:67)
at dk.rhos.healthcare.epr.comp.patient.impl.services.patient.PatientServicesBean.aw$original$_AW_$getPatientById$_AW_$dk_rhos_healthcare_epr_comp_patient_impl_services_patient_PatientServicesBean(PatientServicesBean.java:324)
at dk.rhos.healthcare.epr.comp.patient.impl.services.patient.PatientServicesBean_1__1888871596_433273118___AW_JoinPoint.proceed(Unknown Source)
at dk.rhos.fw.rampart.common.errorhandling.handler.ejb.EJBExceptionHandler.invoke(EJBExceptionHandler.java:31)
at dk.rhos.healthcare.epr.comp.patient.impl.services.patient.PatientServicesBean_1__1888871596_433273118___AW_JoinPoint.proceed(Unknown Source)
at dk.rhos.healthcare.epr.comp.patient.impl.services.patient.PatientServicesBean_1__1888871596_433273118___AW_JoinPoint.invoke(Unknown Source)
at dk.rhos.healthcare.epr.comp.patient.impl.services.patient.PatientServicesBean.getPatientById(PatientServicesBean.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java(Compiled Code))
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java(Compiled Code))
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
at dk.rhos.fw.rampart.common.request.RequestContextService.exec(RequestContextService.java:40)
at dk.rhos.healthcare.epr.comp.patient.impl.services.patient.EJSRemoteStatelessPatientServices_8a8329f5.exec(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java(Compiled Code))
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java(Compiled Code))
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
at com.ibm.rmi.util.ProxyUtil$4.run(ProxyUtil.java:727)
at java.security.AccessController.doPrivileged1(Native Method)
at java.security.AccessController.doPrivileged(AccessController.java(Compiled Code))
at com.ibm.rmi.util.ProxyUtil.invokeWithClassLoaders(ProxyUtil.java:725)
at com.ibm.CORBA.iiop.ClientDelegate.invoke(ClientDelegate.java:1123)
at $Proxy8.exec(Unknown Source)
at dk.rhos.healthcare.epr.comp.patient.impl.services.patient._PatientServices_Stub.exec(_PatientServices_Stub.java:283)
at dk.rhos.fw.rampart.common.request.RequestContextPropagationInterceptor.invoke(RequestContextPropagationInterceptor.java:43)
at $Proxy8.getPatientById(Unknown Source)
at dk.rhos.healthcare.epr.comp.patient.impl.services.patient.PatientServicesDelegate$PatientServicesRemoteProxy.getPatientById(PatientServicesDelegate.java:589)
at dk.rhos.healthcare.epr.comp.patient.impl.services.patient.PatientServicesDelegate.getPatientById(PatientServicesDelegate.java:232)
at dk.rhos.healthcare.epr.comp.patient.impl.services.patientpoc.command.FindPatientPresencesCommand.getPatientById(FindPatientPresencesCommand.java:120)
at dk.rhos.healthcare.epr.comp.patient.impl.services.patientpoc.command.FindPatientPresencesCommand.createSearchPatients(FindPatientPresencesCommand.java:105)
at dk.rhos.healthcare.epr.comp.patient.impl.services.patientpoc.command.FindPatientPresencesCommand.doExecute(FindPatientPresencesCommand.java:75)
at dk.rhos.healthcare.epr.comp.patient.impl.services.common.Command.execute(Command.java:67)
at dk.rhos.healthcare.epr.comp.patient.impl.services.patientpoc.PatientPOCServicesBean.aw$original$_AW_$findPatientPresences$_AW_$dk_rhos_healthcare_epr_comp_patient_impl_services_patientpoc_PatientPOCServicesBean(PatientPOCServicesBean.java:97)
at dk.rhos.healthcare.epr.comp.patient.impl.services.patientpoc.PatientPOCServicesBean_1__1469534095_337587872___AW_JoinPoint.proceed(Unknown Source)
at dk.rhos.fw.rampart.common.errorhandling.handler.ejb.EJBExceptionHandler.invoke(EJBExceptionHandler.java:31)
at dk.rhos.healthcare.epr.comp.patient.impl.services.patientpoc.PatientPOCServicesBean_1__1469534095_337587872___AW_JoinPoint.proceed(Unknown Source)
at dk.rhos.healthcare.epr.comp.patient.impl.services.patientpoc.PatientPOCServicesBean_1__1469534095_337587872___AW_JoinPoint.invoke(Unknown Source)
at dk.rhos.healthcare.epr.comp.patient.impl.services.patientpoc.PatientPOCServicesBean.findPatientPresences(PatientPOCServicesBean.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java(Compiled Code))
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java(Compiled Code))
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
at dk.rhos.fw.rampart.common.request.RequestContextService.exec(RequestContextService.java:40)
at dk.rhos.healthcare.epr.comp.patient.impl.services.patientpoc.EJSRemoteStatelessPatientPOCServices_73564986.exec(Unknown Source)
at dk.rhos.healthcare.epr.comp.patient.impl.services.patientpoc._EJSRemoteStatelessPatientPOCServices_73564986_Tie.exec(_EJSRemoteStatelessPatientPOCServices_73564986_Tie.java:183)
at dk.rhos.healthcare.epr.comp.patient.impl.services.patientpoc._EJSRemoteStatelessPatientPOCServices_73564986_Tie._invoke(_EJSRemoteStatelessPatientPOCServices_73564986_Tie.java:91)
at com.ibm.CORBA.iiop.ServerDelegate.dispatchInvokeHandler(ServerDelegate.java:610)
at com.ibm.CORBA.iiop.ServerDelegate.dispatch(ServerDelegate.java:463)
at com.ibm.rmi.iiop.ORB.process(ORB.java:439)
at com.ibm.CORBA.iiop.ORB.process(ORB.java:1737)
at com.ibm.rmi.iiop.Connection.doWork(Connection.java:2260)
at com.ibm.rmi.iiop.WorkUnitImpl.doWork(WorkUnitImpl.java:65)
at com.ibm.ejs.oa.pool.PooledThread.run(ThreadPool.java:95)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))

Name and version of the database you are using:
Oracle 10

The generated SQL (show_sql=true):


Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject: More than one row with the given identifier was found
PostPosted: Tue Feb 28, 2006 4:14 am 
Beginner
Beginner

Joined: Tue Feb 15, 2005 8:14 am
Posts: 32
Forgot the generated sql...

select patient0_.id as id1_, patient0_.canonicalRepresentationId as canonica2_1_, patient0_.personId as personId1_, patient0_.maritalstatus_sid as maritals4_1_, patient0_.maritalstatus_cid as maritals5_1_, patient0_.gender_sid as gender_sid1_, patient0_.gender_cid as gender_cid1_, patient0_.physician as physician1_, patient0_.deathDate as deathDate1_, patient0_.created as created1_, patient0_.createdBy as createdBy1_, patient0_.updated as updated1_, patient0_.updatedBy as updatedBy1_, patient0_.persistenceVersion as persist14_1_, person1_.id as id0_, person1_.givenName as givenName0_, person1_.familyName as familyName0_, person1_.addressingName as addressi4_0_, person1_.privacyProtected as privacyP5_0_, person1_.citizenship_sid as citizens6_0_, person1_.citizenship_cid as citizens7_0_, person1_.created as created0_, person1_.createdBy as createdBy0_, person1_.updated as updated0_, person1_.updatedBy as updatedBy0_, person1_.persistenceVersion as persist12_0_ from pat_patient patient0_ left outer join pat_person person1_ on patient0_.personId=person1_.id where patient0_.id=?


Top
 Profile  
 
 Post subject: found the solution
PostPosted: Tue Feb 28, 2006 4:23 am 
Beginner
Beginner

Joined: Tue Feb 15, 2005 8:14 am
Posts: 32
I found the error, on the database some contraints where disabled.... so there where 2 persons with the same id..


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.