org.hibernate.HibernateException: More than one row with the given identifier was found: 1, for class: com.ldb.mdac.PhysicalTableRole

Hibernate JIRA | Ravi Kumar | 1 year ago
  1. 0

    Lets say there are two POJO entities defined 'DataModelGroup' and 'PhysicalTableRole'. The entities are annotated with OneToOne bidirectional mapping. According to the OneToOne mapping model, at any point, there should not be more than one PhysicalTableRole assigned to a DataModelGroup and vice-versa. On doing few inserts into the db, figured out that hibernate allows to insert more than one row (pointing to the same DataModelGroup) in PhysicalTableRole which basically violates OneToOne mapping between the objects. Following is the scenario used to reproduced the issue: 1) Open a session. 2) Create a DataModelGroup record (say dmg) into the db. 3) Create a PhysicalTableRole (say ptr1) record and set dmg to it. Insert ptr1 into the db. 4) Close session 5) Begin a new session 6) Create another PhysicalTableRole (say ptr2) record and set dmg to it. Insert ptr2 into the db. After the insertion, there are two rows in table PhysicalTableRole pointing to the same DataModelGroup dmg. 7) Fetch the DataModelGroup record by its id. An exception is thrown by the hibernate : Exception in thread "main" org.hibernate.HibernateException: More than one row with the given identifier was found: 1, for class: com.ldb.mdac.PhysicalTableRole at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:86) at org.hibernate.loader.entity.EntityLoader.loadByUniqueKey(EntityLoader.java:143) at org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:2046) at org.hibernate.type.EntityType.loadByUniqueKey(EntityType.java:775) at org.hibernate.type.EntityType.resolve(EntityType.java:496) at org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:153) at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:127) at org.hibernate.loader.plan.exec.process.internal.AbstractRowReader.performTwoPhaseLoad(AbstractRowReader.java:227) at org.hibernate.loader.plan.exec.process.internal.AbstractRowReader.finishUp(AbstractRowReader.java:198) at org.hibernate.loader.plan.exec.process.internal.ResultSetProcessorImpl.extractResults(ResultSetProcessorImpl.java:123) at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:121) at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:85) at org.hibernate.loader.entity.plan.AbstractLoadPlanBasedEntityLoader.load(AbstractLoadPlanBasedEntityLoader.java:167) at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3890) at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:486) at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:451) at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:196) at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:258) at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:134) at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1071) at org.hibernate.internal.SessionImpl.access$2600(SessionImpl.java:164) at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2623) at org.hibernate.internal.SessionImpl.get(SessionImpl.java:955) at com.ldb.mdac.App.main(App.java:42) I am also attaching a sample hibernate application to reproduce the error.

    Hibernate JIRA | 1 year ago | Ravi Kumar
    org.hibernate.HibernateException: More than one row with the given identifier was found: 1, for class: com.ldb.mdac.PhysicalTableRole
  2. 0

    Lets say there are two POJO entities defined 'DataModelGroup' and 'PhysicalTableRole'. The entities are annotated with OneToOne bidirectional mapping. According to the OneToOne mapping model, at any point, there should not be more than one PhysicalTableRole assigned to a DataModelGroup and vice-versa. On doing few inserts into the db, figured out that hibernate allows to insert more than one row (pointing to the same DataModelGroup) in PhysicalTableRole which basically violates OneToOne mapping between the objects. Following is the scenario used to reproduced the issue: 1) Open a session. 2) Create a DataModelGroup record (say dmg) into the db. 3) Create a PhysicalTableRole (say ptr1) record and set dmg to it. Insert ptr1 into the db. 4) Close session 5) Begin a new session 6) Create another PhysicalTableRole (say ptr2) record and set dmg to it. Insert ptr2 into the db. After the insertion, there are two rows in table PhysicalTableRole pointing to the same DataModelGroup dmg. 7) Fetch the DataModelGroup record by its id. An exception is thrown by the hibernate : Exception in thread "main" org.hibernate.HibernateException: More than one row with the given identifier was found: 1, for class: com.ldb.mdac.PhysicalTableRole at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:86) at org.hibernate.loader.entity.EntityLoader.loadByUniqueKey(EntityLoader.java:143) at org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:2046) at org.hibernate.type.EntityType.loadByUniqueKey(EntityType.java:775) at org.hibernate.type.EntityType.resolve(EntityType.java:496) at org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:153) at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:127) at org.hibernate.loader.plan.exec.process.internal.AbstractRowReader.performTwoPhaseLoad(AbstractRowReader.java:227) at org.hibernate.loader.plan.exec.process.internal.AbstractRowReader.finishUp(AbstractRowReader.java:198) at org.hibernate.loader.plan.exec.process.internal.ResultSetProcessorImpl.extractResults(ResultSetProcessorImpl.java:123) at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:121) at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:85) at org.hibernate.loader.entity.plan.AbstractLoadPlanBasedEntityLoader.load(AbstractLoadPlanBasedEntityLoader.java:167) at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3890) at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:486) at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:451) at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:196) at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:258) at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:134) at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1071) at org.hibernate.internal.SessionImpl.access$2600(SessionImpl.java:164) at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2623) at org.hibernate.internal.SessionImpl.get(SessionImpl.java:955) at com.ldb.mdac.App.main(App.java:42) I am also attaching a sample hibernate application to reproduce the error.

    Hibernate JIRA | 1 year ago | Ravi Kumar
    org.hibernate.HibernateException: More than one row with the given identifier was found: 1, for class: com.ldb.mdac.PhysicalTableRole
  3. 0

    Sauntering Coder: Compounding Hibernate Problems

    blogspot.com | 8 months ago
    org.hibernate.HibernateException: More than one row with the given identifier was found: 1, for class: Owners
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Do the reception of a participant On another firefox try to do the reception of the same participant give to each one a different number save each one go to interview and you will receive: WicketMessage: Can't instantiate page using constructor public org.obiba.onyx.webapp.participant.page.InterviewPage() Root cause: org.hibernate.HibernateException: More than one row with the given identifier was found: 26, for class: org.obiba.onyx.core.domain.participant.Participant at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:69) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42) at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3049) at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:399) 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:195) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103) at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878) at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815) at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808) at org.obiba.core.service.impl.hibernate.PersistenceManagerHibernateImpl.get(PersistenceManagerHibernateImpl.java:54) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.inv

    JIRA | 8 years ago | Nathalie Émond
    org.hibernate.HibernateException: More than one row with the given identifier was found: 26, for class: org.obiba.onyx.core.domain.participant.Participant
  6. 0

    Hibernate: More than one row with the given identifier was found error

    Stack Overflow | 2 years ago | Angelo Immediata
    it.eng.comi.exception.CoMiDbException: Errore nella ricerca con detached criteria DetachableCriteria(CriteriaImpl(it.eng.comi.spring.dao.hibernate.models.MediaGalleryTree:this[][id=4])); More than one row with the given identifier was found: 2, for class: it.eng.comi.spring.dao.hibernate.models.MediaGalleryTree

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.hibernate.HibernateException

      More than one row with the given identifier was found: 1, for class: com.ldb.mdac.PhysicalTableRole

      at org.hibernate.loader.entity.AbstractEntityLoader.load()
    2. Hibernate
      TwoPhaseLoad.initializeEntity
      1. org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:86)
      2. org.hibernate.loader.entity.EntityLoader.loadByUniqueKey(EntityLoader.java:143)
      3. org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:2046)
      4. org.hibernate.type.EntityType.loadByUniqueKey(EntityType.java:775)
      5. org.hibernate.type.EntityType.resolve(EntityType.java:496)
      6. org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:153)
      7. org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:127)
      7 frames
    3. org.hibernate.loader
      AbstractLoadPlanBasedEntityLoader.load
      1. org.hibernate.loader.plan.exec.process.internal.AbstractRowReader.performTwoPhaseLoad(AbstractRowReader.java:227)
      2. org.hibernate.loader.plan.exec.process.internal.AbstractRowReader.finishUp(AbstractRowReader.java:198)
      3. org.hibernate.loader.plan.exec.process.internal.ResultSetProcessorImpl.extractResults(ResultSetProcessorImpl.java:123)
      4. org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:121)
      5. org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:85)
      6. org.hibernate.loader.entity.plan.AbstractLoadPlanBasedEntityLoader.load(AbstractLoadPlanBasedEntityLoader.java:167)
      6 frames
    4. Hibernate
      SessionImpl.get
      1. org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3890)
      2. org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:486)
      3. org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:451)
      4. org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:196)
      5. org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:258)
      6. org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:134)
      7. org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1071)
      8. org.hibernate.internal.SessionImpl.access$2600(SessionImpl.java:164)
      9. org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2623)
      10. org.hibernate.internal.SessionImpl.get(SessionImpl.java:955)
      10 frames
    5. com.ldb.mdac
      App.main
      1. com.ldb.mdac.App.main(App.java:42)
      1 frame