Today I inserted 1 data in an SSH that operates two databases
Error illegal attempt to associate a collection with both open sessions
Here are the answers: http://fuaotech.iteye.com/blog/1298826
Use the Hibenate merge method instead of Save, update, and so on.
The merge and Saveorupdate methods differ in that the merge method is the object that transforms the object we provide into a managed state, whereas saveorupdate turns the object we provide into a persisted object. , said the popular point is: Saveorupdate after the object will be included in the session management, the state of the object will be synchronized with the database, query the object will be directly from the session, the merge object will not be included in the session management, The object will be queried again or taken from the database. So the general recommendation is to use the merge
This.gethibernatetemplate (). Save (data) in the Missiondaoimpl class. The Save method is changed to the merge method
Use this method: public boolean addData (Object data) throws Exception {
This.gethibernatetemplate (). Save (data);
return true;
}
Operation of two databases simultaneously: error illegal attempt to associate a collection with two open sessions