Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Any way to force JdbcTemplate to use a specific Connection?

  1. #11
    Join Date
    Feb 2005
    Location
    Boston, MA
    Posts
    1,142

    Default

    Oh, and the reason why I wasn't that fond of using the SingleConnectionDataSource was because I could find a way of doing it while still keeping my business objects stateless. Although with a ThreadLocal SingleConnectionDataSource it might be possible.

  2. #12
    Join Date
    Aug 2004
    Posts
    1,107

    Default

    Thinking about it a little bit more, a ThreadConnectionDataSourc might be a good complement to the SingleConnectionDataSource. The trouble is detecting when one Session ends and the next Session starts running on a specific thread. Somehow your application would have to signal these events.
    Thomas Risberg
    SpringSource by Pivotal
    http://www.springsource.org

  3. #13
    Join Date
    Aug 2004
    Posts
    1,107

    Default

    I guess wrapping the service method with an AOP around advice would work here.
    Thomas Risberg
    SpringSource by Pivotal
    http://www.springsource.org

  4. #14
    Join Date
    Aug 2004
    Location
    Linz, Austria
    Posts
    391

    Default

    Note that you could still leverage Spring transaction demarcation without an actual database transaction backing it: through specifying "PROPAGATION_SUPPORTS" with the default synchronization behavior.

    Even in case of SUPPORTS, Spring will still activate transaction synchronization for the demarcated scope, allowing data access code to synchronize its resources accordingly. This will lead to the same JDBC Connection (and Hibernate Session etc) used throughout that scope, even without an actual database transaction.

    No need for a SingleConnectionDataSource or the like in this scenario. This seems to be what you want to achieve... and you would get it without any custom coding.

    Juergen

  5. #15
    Join Date
    Sep 2004
    Location
    Copenhagen, Denmark
    Posts
    113

    Default

    Quote Originally Posted by Juergen Hoeller
    Note that you could still leverage Spring transaction demarcation without an actual database transaction backing it: through specifying "PROPAGATION_SUPPORTS" with the default synchronization behavior.

    Even in case of SUPPORTS, Spring will still activate transaction synchronization for the demarcated scope, allowing data access code to synchronize its resources accordingly. This will lead to the same JDBC Connection (and Hibernate Session etc) used throughout that scope, even without an actual database transaction.

    No need for a SingleConnectionDataSource or the like in this scenario. This seems to be what you want to achieve... and you would get it without any custom coding.

    Juergen
    Wau sounds cool. Shouldn't this be documented in the reference manual?
    /Claus

  6. #16
    Join Date
    Feb 2005
    Location
    Boston, MA
    Posts
    1,142

    Default

    Quote Originally Posted by Juergen Hoeller
    Note that you could still leverage Spring transaction demarcation without an actual database transaction backing it: through specifying "PROPAGATION_SUPPORTS" with the default synchronization behavior.
    Wow. This is exactly what I was looking for. Thanks.

Similar Threads

  1. Replies: 8
    Last Post: Jul 26th, 2005, 07:33 AM
  2. CMT, JdbcTemplate and connection pools
    By jayschm in forum EJB
    Replies: 3
    Last Post: Apr 25th, 2005, 08:11 AM
  3. Replies: 0
    Last Post: Apr 6th, 2005, 08:24 AM
  4. Replies: 8
    Last Post: Jan 9th, 2005, 10:24 AM
  5. Replies: 1
    Last Post: Aug 15th, 2004, 06:40 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
  •