here for example is what has to be done in order to work with this
without creating loads of orphans.
public void updateMyDetails(SystemUserDetails systemUserDetails,
String username) {
//get the Session instance already bound to current thread and opened
Session session = SessionFactoryUtils.getSession(getSessionFactory(),
false);
try {
SystemUser systemUser;
List list = session
.find(
"From SystemUser as systemUser where systemUser.username = ?",
username, Hibernate.STRING);
if (!list.isEmpty()) {
systemUser = (SystemUser) list.get(0);
SystemUserDetails originalDetails = systemUser
.getSystemUserDetails();
if (originalDetails != null) {
systemUserDetails.setId(originalDetails.getId());
}
session.evict(originalDetails);
systemUser.setSystemUserDetails(systemUserDetails);
session.update(systemUser);
_________________ Pesimist: The glass is half empty
Optimist: The glass is half full
Engineer:The glass should be half that size
|