Hi! I know that this is more a hibernate than a tapestry question, but i am not sure if my question is really more hibernate specific, or a standard problem.
If i am logged in as User user with session x, but some values of my user get changed from the outside of a session y my User user in my session x has still the "old" values. If i am now persisting my User user from session x, the new values from session y are overwritten and are therefore lost. I am merging the object via DAO.merge - but it seems that hibernate does not know which values are old, and new. So the question is, what do i have to do, to ensure that my user object retrieved from my DB is always uptodate? merge function: public T merge(T detachedInstance) { logger.debug("Merging " + detachedInstance + "."); try { Date now = new Date(); detachedInstance.setUpdatedAt(now); T result = getHibernateTemplate().merge(detachedInstance); return result; } catch (RuntimeException re) { logger.error("Merging " + detachedInstance + " failed.", re); throw re; } } This is the way i am getting my user object (but this object is never updated if i am changing some values of the user directly in the DB - only if i am login out and in again: UserService.java public User getCurrentUser() { return authenticationHelper.getPrincipal(); } AuthenticationHelper.java public User getPrincipal() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); User user = null; if (authentication != null) { // is user logged in? AirwritingUserDetails userDetail = (AirwritingUserDetails) authentication.getPrincipal(); user = userDetail.getUser(); } return user; } AirwritingUserDetails.java public abstract class AirwritingUserDetails extends org.springframework.security.core.userdetails.User { private User user; public AirwritingUserDetails(User user, Collection<? extends GrantedAuthority> authorities) { super(user.getUsername(), user.getPassword(), user.getStatus() == Status.ACTIVE, true, true, true, authorities); this.user = user; } public User getUser() { return user; } } -- View this message in context: http://tapestry.1045711.n5.nabble.com/Hibernate-springframework-security-question-tp5717207.html Sent from the Tapestry - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org