Automatic Hibernate Transaction Management with Spring?

前端 未结 2 635
长发绾君心
长发绾君心 2020-12-13 21:55

How far does the spring framework go with transaction handling? My reading of the book \"Spring In Action\" suggestions with its examples that you create DAO methods that do

2条回答
  •  北海茫月
    2020-12-13 22:26

    Spring provides at least 3 ways of transaction demarcation:

    1) Programmatic handling, via TransactionTemplate or PlatformTransactionManager - light on config, but invasive

    2) Declarative via XML - verbose XML, but non-invasive

    3) Declarative via annotations - light on XML, not invasive

    Which one you pick depends on which one best suits your needs, Spring doesn't make that choice for you. From your question, it sounds like the annotation approach is what you're after.

    I suggest reading the Spring reference manual, the section of annotation-driven transaction handling. It's clear and concise.

    I always consult the ref docs first, and only consult a book if it's not in the docs.

提交回复
热议问题