NonUniqueObjectException
...
Here is another instance of code where one may see NonUniqueObjectException
Panel |
---|
Patient patient = null; try { catch(ClassCastException ex){ .... Context.getPatientService().savePatient(patient); // It throws NonUniqueObjectException |
The Problem appears when ClassCastException is thrown.
...
A possible solution to this could be to explicitly evict one of the objects from the hibernate session. The best approach would be to add this call in a finally block to guarantee that always one person object remains in the hibernate session with the given patientId.
Panel |
---|
Patient patient = null; try { } catch(ClassCastException ex){ finally { // removing the person object from session making sure only one object with a given id is present if (patient!=null) } ... Context.getPatientService().savePatient(patient); |
This will possibly resolve the error.