Results 1 to 3 of 3

Thread: LAZY AND PROPAGATION_REQUIRED

  1. #1

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    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.
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

  3. #3

    Default

    Ok Collin, i understand.

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

    Thanks,

    Fabien

Similar Threads

  1. Replies: 2
    Last Post: Dec 8th, 2005, 09:00 AM
  2. Hibernate and Lazy Loading.
    By cmrudd in forum Data
    Replies: 1
    Last Post: Oct 3rd, 2005, 03:58 AM
  3. iBatis lazy load transaction issues.
    By efpiva in forum Data
    Replies: 3
    Last Post: Jun 22nd, 2005, 06:20 PM
  4. Replies: 4
    Last Post: Jun 20th, 2005, 10:52 AM
  5. Spring, JSF, Hibernate & Lazy Collections
    By e.medina.m in forum Data
    Replies: 3
    Last Post: Mar 9th, 2005, 03:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •