Announcement Announcement Module
Collapse
No announcement yet.
Transient object in session referencing a persistent object Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Transient object in session referencing a persistent object

    Hi,
    I have a problem in my application with a preview functionality. Maybe somebody can help me - that would truly be great.
    I have a form (SimpleFormController) which controls a transient object (="formBackingObject" returns a new transient object). Before the object is finally made persistent (by a "save"-Button within the form), the user can preview the object on another form, that means he is transferred to another FormController. The user can then go back to the original form and save the object.
    I transfer the object between the two Controllers by putting it into the session. This works fine as long as the new transient object does not reference any existing persistent object. In my case, it may reference a predefined, persistent object. In this case, an Exception of the following type is thrown: "org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed". This makes sense, because the session, in which the reference was set, is no longer alive in subsequent HTTPRequests.
    Is there any good way to solve this problem?
    Thanks in advance, Heiko

  • #2
    Hi,

    I think this post belongs to the thread 'Data Access'.

    Anyway accroding to the information you provided, when loading a persistent object, it seems that you havent load the child objects/ collections associate with that object. Meaning that you load the object 'lazily'. If you think that this object should be loaded lazily then what you can do is before accesing the object you can load associated collections. Or you can eagerly load the object- meaning that collections/child objects associated with it are loaded the same time.

    -/Viraj

    Comment

    Working...
    X