Announcement Announcement Module
Collapse
No announcement yet.
Same session for my swing application Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Same session for my swing application

    Hi, I'm developing a swing application using Spring + Hibernate.
    I don't understand how to avoid that Spring open and close the session every time I call my dao service.

    In other words:
    Step 1 -> load, by HibernateTemplate execute, an object that represent a Car
    Step 2 -> I'd like to use Hibernate.initialize(car.getOptionals()) to initialize a lazy loading collection

    The problem is that when I call the Hibernate.initialize method Spring throws an exception like this "HibernateException: disconnected session".
    I could solve the problem by set lazy = false to the optionals collection but this damage the performance.
    I think that the problem is due to Spring configuration that close session after every operation over database, so my car object is detached and is unable to use lazy loading.

    Could I change this behavior and use the same session in my swing application ?

    Thanks at all

  • #2
    I would guess your problem is the Session has closed and you are trying to initialize detached instances. You'd need to reattach the entity to the Session before trying to load them.
    http://www.hibernate.org/hib_docs/v3...state-detached
    Last edited by karldmoore; Aug 30th, 2007, 06:25 AM.

    Comment


    • #3
      Thank you. With your advice I solved the problem.

      Comment


      • #4
        Fantastic, glad you got it working! Which solution did you go with?
        Last edited by karldmoore; Aug 30th, 2007, 06:25 AM.

        Comment

        Working...
        X