Hi, I've got the following situation:
- on application startup a list of user objects got fetched from the database
- later a meeting object got fetched from the database, containing a list of
attending users. These users are other user objects than the ones loaded on
startup, because the meeting got loaded in its own session.
- now the meeting gets modified. for every modification a history message is
added to the meeting, containing a timestamp and the current logged in user
(which is obviously an user object from the list fetched at application startup).
- when trying to store the modified meeting to the database, hibernate throws
the following exception: "a different object with the same identifiert value was
already associated with the session". hibernate's right here, there are user
objects from the global user list fetched at startup and user objects fetched
with the meeting pointing to the same identifier.
What would be the appropriate solution ? I need this global user list for
speed reasons. Do I have to sess.update() every global user object every
time a new session gets created ? Or should I use just one session over the
whole application lifetime ? The FAQ states to use a session per database
transaction, but what about long lasting objects from previous transactions ?
Or is my application "broken by design" ?
Regards,
Axel
|