[DH-OFFICE] 23:50:30 error [http-8080-5] newsaction. save (128) | a different object with the same Identifier value was already associated with the session: [com.sencloud.dh.oa.model.info. news #10060]; Nested exception is Org. hibernate. nonuniqueobjectexception: a different object with the same Identifier value was already associated with the session: [com.sencloud.dh.oa.model.info. news #10060]
This problem occurs today: you can solve it in the following ways.
1. A different object with the same Identifier value was already associated with the session.
cause of error: two identical identifiers but different entities exist in the same session in hibernate.
solution 1: Session. clean ()
PS: If saveorupdate (object) and other operations to change the data status are performed after the clean operation, "Found two representations of same Collection" may be reported.
solution 2: Session. refresh (object)
PS: when the object is not an existing data object in the database, the session cannot be used. refresh (object) because this method is used to retrieve the object from the hibernate session, if this object does not exist in the session, an error is returned. Therefore, when you use saveorupdate (object) you need to judge before.
solution 3: Session. Merge (object)
PS: the built-in method in hibernate, which is recommended.
2. Found two representations of same collection
cause of error: See figure 1.
solution: Session. Merge (object)
the preceding two exceptions often occur in one-to-multiple ing and multiple-to-multiple ing.