Results 1 to 6 of 6

Thread: Service without transactions fails to close Hibernate sess

  1. #1
    Join Date
    Aug 2004
    Location
    Columbus, OH, USA
    Posts
    133

    Default Service without transactions fails to close Hibernate sess

    I have a business service that has to perform reiterative queries against two Hibernate DAOs (each working against a different data source).

    I can't wrap the service in a JTA transaction because one of the DBs doesn't support transactions at all (it's a legacy turnkey system).

    The first query to each DAO works fine, but the second query kicks out "SessionImpl.finalize - unclosed connection, forgot to call close() on your session?" and the service hangs. I suspect this is because Spring isn't managing Hibernate's sessions since a transaction isn't wrapped around the service, right?

    What are my options until the turnkey system suports JTA transactions? :?

    Thanks in advance,
    Scott

  2. #2
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    A dummy subclass of AbstractPlatformTransactionManager, with no ops for doCommit and doRollback, might do the trick. Haven't tried it--just thinking aloud.
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

  3. #3
    Join Date
    Aug 2004
    Location
    Columbus, OH, USA
    Posts
    133

    Default

    That's interesting. But wouldn't something need to flush and close the Hibernate sessions?

    Scott

  4. #4
    Join Date
    Aug 2004
    Location
    Columbus, OH, USA
    Posts
    133

    Default

    Wondering if anyone else has ideas...?

    Thanks in advance,
    Scott

  5. #5
    Join Date
    Aug 2004
    Location
    Columbus, OH, USA
    Posts
    133

    Default

    For what it's worth I did a bunch or research into configuring JTA to work with MySQL (which doesn't have XA drivers as far as I can tell) and an Informix database that doesn't have logging turned on and have opted to give up on the JTA route for now.

    Rod, I think you're right - subclassing AbstractPlatformTransactionManager seems to be the most straightforward course at this point.

    If I'm going to do this, would there be any interest in a "HibernateTransactionManager" that accepts a list of sessionFactories or dataSources? It's not JTA, but it might be useful to others working with multiple JDBC-only and Hibernate-only datasources. Just trying to determine how much time I should spend on making this subclass useful for other environments.

    Thanks,
    Scott

  6. #6
    Join Date
    Aug 2004
    Location
    Columbus, OH, USA
    Posts
    133

    Default

    Argh, encountering some show-stoppers. See http://forum.springframework.org/viewtopic.php?t=3765 .

    Scott

Similar Threads

  1. Hibernate Long Session Per Flow?
    By akw in forum Web Flow
    Replies: 21
    Last Post: Dec 12th, 2005, 08:06 PM
  2. Replies: 2
    Last Post: Aug 31st, 2005, 12:37 PM
  3. Replies: 9
    Last Post: Feb 8th, 2005, 09:25 PM
  4. Replies: 3
    Last Post: Nov 19th, 2004, 07:16 PM
  5. Replies: 7
    Last Post: Aug 21st, 2004, 03:42 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
  •