"HibernateException: More than one row with the given identifier was found" in Hibernate
Issue
- Encountering failure during load or merge of an entity
... org.hibernate.HibernateException: More than one row with the given identifier was found: John, for class: org.hibernate.entity.Employee
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:90)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:54)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:4289)
at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:597)
at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:565)
at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:226)
at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:350)
at org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad(DefaultLoadEventListener.java:127)
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:93)
at org.hibernate.internal.SessionImpl.fireLoadNoChecks(SessionImpl.java:1277)
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1265)
at org.hibernate.internal.SessionImpl.access$2000(SessionImpl.java:208)
at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.doLoad(SessionImpl.java:2901)
at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2875)
at org.hibernate.internal.SessionImpl.get(SessionImpl.java:1102)
at org.hibernate.event.internal.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:322)
at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:188)
at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:72)
at org.hibernate.internal.SessionImpl.fireMerge(SessionImpl.java:905)
...
Environment
- Red Hat JBoss Enterprise Application Platform (EAP) 7
- Hibernate 5
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.