Results 1 to 6 of 6

Thread: simplejdbctemplate question

  1. #1
    Join Date
    Mar 2005
    Posts
    144

    Default simplejdbctemplate question

    Hello,

    If I set up a simple "save" method in my DAO (simplejdbctemplate), do I need to define transactional boundaries explicitly or will spring commit by default (without the need to set up a transaction mgr).

  2. #2
    Join Date
    Mar 2005
    Posts
    144

    Default Unexpected behaviour

    Ok, this is what I am seeing... If I update the database 3 times, I only see my first two updates reflected in the database. As you would expect, if I updated it 4 times, only 3 updates are reflected in the DB. It seems as though the last update transaction is not being committed. Any ideas why this would be?

  3. #3

    Default

    if you define a DAO method as transactional, spring will commit or rollback that transaction automatically.

    if you do 3 operations and can only see 2 operations in DB, you would have to do a logger displaying what's happening.

    without more info I can not say more, sorry.

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    Basically said, no transactionmanager and no transaction configuration is no transactions is no insert/delete/update to the database. Only if you use a database that doesn't support transactions (like MySQL with MyISAM tables) you might see data in the database.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5
    Join Date
    Mar 2005
    Posts
    144

    Default Looking for documentation...

    No transaction manager is required if I am using "plain old" JDBC. If I am using Spring JDBC though, a transaction manager is required? I knew this was required when using ORM tools like hibernate, but for some reason, I thought this was optional for Spring JDBC.

    I have been looking through the documentation and have not found some wording that says that a transaction manager is always required. I would like to better understand this. If you know where this is, please let me know.

    Thanks for your help.

  6. #6
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    You need transactions even if you do plain old jdbc, you would start a transaction yourself or use auto commit (which i don't hope you ever did!). You would do ask the connection to start a transaction and in the end commit or rollback.

    The DataSourceTransactionManager (TransactionManager is the abstraction for spring).

    Again delete/update/insert without Transactions is useless, for spring that means configuring a transactionmanager.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

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