Error "Different objects with the same identifiers"

I use RMI + Hibernate in a Java project, and I am having problems with NotUniqueException with the error "Various objects with the same identifier".

I have a few doubts:

  • I am pretty sure that I am not copying or creating new objects with the same ntifiers ideas. Is it possible that RMI creates a new object from another when I use it?

  • Which method does Hibernate use to know that two objects are the same? equally?

  • I know that Serializable is related to Hibernate, but I don’t know how?

  • How can I solve the "Differents objects" error using RMI at the same time?

  • Is this correct every time I use delete or save over merge object before?

Stack trace:

org.orm.PersistentException: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [dcl.Administrador#10] at org.orm.PersistentSession.saveOrUpdate(PersistentSession.java:648) at org.orm.PersistentManager.saveObject(PersistentManager.java:274) at dcl.AdministradorDAO.save(AdministradorDAO.java:240) at dcl.BdAdministrador.guardarAdministrador(BdAdministrador.java:62) at dcl.BdAdministrador.actualizarAdministrador(BdAdministrador.java:109) at dcl.BdPrincipal.actualizarAdministrador(BdPrincipal.java:555) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source) at sun.rmi.transport.Transport$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Unknown Source) at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) 

Thanks in advance.

+4
source share
1 answer

If you are doing something like returning a hibernation object from an RMI method, and then passing it back to another, you may need to re-bind the object to the session. (see What is the correct way to reattach individual objects in Hibernate? ).

You may receive additional information about what you are trying if this does not help.

0
source

All Articles