Hi,
I have a class A and a Class B mapped to the same table X.
The requirement is to find out duplicate data records that might have been inserted in table X.
Hence I have a configuration which is: class A - corresponds to each data record. a list of class B objects contained within class A, which essentially all the records in the table X.
I can compare class A object with the each one in the list of class B objects I can find out the duplicates.
I have a many to one relationship between Class A and Class B.
I am trying to implement this logic...However I am getting the following exception:
Caused by: org.hibernate.HibernateException: More than one row with the given identifier was found: , for class: com.sample.Class A at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:69) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42) at org.hibernate.loader.entity.BatchingEntityLoader.load(BatchingEntityLoader.java:82) at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3038) at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395) at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375) at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:179) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103) at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878) at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:846) at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:557) at org.hibernate.type.EntityType.resolve(EntityType.java:379) at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116) at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842) at org.hibernate.loader.Loader.loadSingleRow(Loader.java:276) at org.hibernate.impl.ScrollableResultsImpl.prepareCurrentRow(ScrollableResultsImpl.java:231) at org.hibernate.impl.ScrollableResultsImpl.next(ScrollableResultsImpl.java:100) ... 2 more
Can you please advise?
Please suggest any better way of doing this if any?
|