Results 1 to 6 of 6

Thread: Hibernate 3 and StatelessSession

  1. #1

    Default Hibernate 3 and StatelessSession

    Hi,
    I've developed my dao layer using Hibernate 3, HibernateDaoSupport and transaction/session managed by Spring at the service layer (I do have services that do use daos, but only services are wrapped to automatically open transactions and sessions).

    Now, for a very few calls I'd need to work with StatelessSessions, basically to improve performance since I have to load a ton of objects that I need to send directly to a rich client without modifications.

    Is there a suggested approach to use stateless sessions in daos that otherwise would use HibernateTemplate?

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    The current Hibernate support relies only on HB session. Since StatelessSession and Session are totally different there isn't any sharing that can be done between them.
    One quick solution is to create StatelessSessions based on the underlying connection of an normal Session class. This way, the StatelessSession will be enlisted in the undergoing transaction.
    Please raise an issue on JIRA so such functionality can be incorporated in future Spring releases.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3

    Default

    I tried that already, but Hibernate wasn't happy about it, and threw an error complaining about a possible concurrent modification of some internal data structure (there was none, it was a simple unit test).

    It seems the two cannot be mixed easily...

  4. #4
    Join Date
    Aug 2009
    Posts
    2

    Default

    Hi aaime,

    I also tried Costin's suggestion but it gives the session conflict as you mentioned.

    So finally did you manage to find any way to open statelessSession with hibernate template?

    whats else is the solution for this problem?
    Any idea?

    Thanks.

  5. #5

    Default

    aaime, see SPR-6202 for more information about the progress for this feature.

  6. #6

    Smile

    Quote Originally Posted by Costin Leau View Post
    The current Hibernate support relies only on HB session. Since StatelessSession and Session are totally different there isn't any sharing that can be done between them.
    One quick solution is to create StatelessSessions based on the underlying connection of an normal Session class. This way, the StatelessSession will be enlisted in the undergoing transaction.
    Please raise an issue on JIRA so such functionality can be incorporated in future Spring releases.

    Really good posting.
    Quite useful.
    Thanks for sharing this here.

Posting Permissions

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