Announcement Announcement Module
Collapse
No announcement yet.
LAZY AND PROPAGATION_REQUIRED Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • LAZY AND PROPAGATION_REQUIRED

    Hi

    I using an hibernate filter for the view, no problem.

    But I don't understand why when i do in a quartz job :

    1. managerCompagny.saveCompany(company);
    2. company.getUsers()

    I have a "lazy exception" for the second line that is just after the first one.

    My "managerCompagny.saveCompany" has PROPAGATION_REQUIRED, so it use a session is exist (if not it creates one) but why close the session after ?

    Excuse me for this stupid question but i want to understand.

    Fabien.

  • #2
    The OpenSessionInView filter is not going to help you for the quartz job, since that's going to happen in a different thread.

    You need to ensure that you encompass both operations 1 and 2 in one transaction. The Session will remain open for the duration of the transaction. One way to do this is by wrapping these 2 operations in one method that is itself transactional.

    Comment


    • #3
      Ok Collin, i understand.

      In fact, i replace company.getUsers() by managerCompagny.getUser(idCompagny), so in my manager with PROPAGATION_REQUIRED.

      Thanks,

      Fabien

      Comment

      Working...
      X