Transaction processing mechanism in SSH, java transaction processing

Updated on society 2024-05-24
9 answers
  1. Anonymous users2024-02-11

    First of all, a transaction is a collection of operations on a database. For example, if multiple pieces of data are inserted into the same transaction, then a unified commit or rollback operation is performed. Successful inserts succeed together and fail together to prevent dirty data from being read into the database.

    In JDBC, we use the Contemporary object for transaction management, which is auto-commit by default. You can close it manually, use commit commit instead, and rollback can be rolled back.

    In Hibernate, it is similar to JDBC, and it is also used in the DAO for transaction management.

    Spring has its own transaction management mechanism, which is managed by TransactionManager, which is generally carried out at the business logic layer.

    Therefore, in SSH, you can choose to use Hibernate for transaction management, or you can choose to use Spring for transaction management. But I personally think that logically speaking, it would be better to use the spring management model, in the service layer, each of our business is actually a real transaction, which may call multiple DAO classes, and carry out multiple operations on multiple databases at the same time, so transaction management here means that everyone will succeed together, and everyone will fail together if they fail. More in line with what we think of as object-oriented programming.

    Therefore, it is recommended that you use Spring for transaction management. The specific ** is available at will.

  2. Anonymous users2024-02-10

    It's written in a lot of space, and there are several books.

  3. Anonymous users2024-02-09

    With Spring, the beans are all managed by Spring, and intercepting a transaction is not a problem!

  4. Anonymous users2024-02-08

    Let me know when you have the answer.

  5. Anonymous users2024-02-07

    Assuming you don't use spring to manage transactions, then do you need a transaction to call a method to open the transaction, do you want to commit the transaction after the operation is completed, and do you want to roll back the transaction if there is an exception, so that if you need a transaction for each method, there are a lot of repetitive transactions, which makes people look like the quality is not high.

    Spring AOP does not need to write those open transactions, commit, and rollback operations by yourself, and Spring has generated these templates for opening transactions, commits, and rollback operations through dynamic **, and only needs to be configured once in the configuration file, without the programmer writing many times by hand.

  6. Anonymous users2024-02-06

    Spring is to use AOP to help you manage things, you don't have to care about the opening of things, rollbacks, etc., if you use Spring, your open things, rollback things can be removed, which can greatly reduce the coupling.

  7. Anonymous users2024-02-05

    First of all, it should be clear that since the SSH framework is used, transactions are managed by Spring, not manually turned on and off. So what you have to pay attention to is not how to turn it on or how to turn it off, but you have to know when to turn it on and when to turn it off.

    The configuration file here automatically manages the methods of the service layer.

    When there are more than 2 transactions in a session, the first transaction is used.

    In addition, the purpose of using currentsession in the general DAO layer is to use the existing session as much as possible in order not to occupy memory space. So it's common to use a session

    Hope it helps

  8. Anonymous users2024-02-04

    ...To understand this, you should first look at the principle of control reversal.

  9. Anonymous users2024-02-03

    Look at the official **.

    Or look at Manjianghong's open source,**:

Related questions
10 answers2024-05-24

In a microprocessor system, the memory unit and the IO port are distinguished by different address codes. >>>More

3 answers2024-05-24

The messaging system of Windows is made up of 3 parts:

Message queues. Windows is able to maintain a message queue for all applications. The application must be fetched from the message queue. >>>More

8 answers2024-05-24

Heat treatment machine, heat treatment is currently the highest heating efficiency, the fastest speed, low consumption, energy saving and environmental protection of metal materials.

7 answers2024-05-24

struts do request processing and **, hibernate does data persistence, spring provides control reversal and AOP services, generally speaking, novices will take some time to understand the role of spring, in layman's terms, it can help you new the class you need, it can be a singleton or a prototype, you can also help you do some interception such as permission interception, internationalization interception, etc., and can also help you manage hibernate such as transaction delivery.

9 answers2024-05-24

Look at the crickets more and stare them for 1 2 hours a day.