I have an error when I want to delete an object from database. The error is:
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.cartif.database.ApplicationField#asd]
To delete an object I do:
public static void delete(Object o){
if(session == null) createSession();
Transaction tx = session.beginTransaction();
tx.begin();
session.delete(o);
tx.commit();
}
When I call this method with an object, I obtain the error. If I debug the application the exception is thrown in tx.begin(); line.
On database this object is unique, as I show in the columns:
name deviceid
"asd" 1
"ElectricalConsumption" 1
"Energy" 1
Why is that happened?
Thanks in advance!