Home > Back-end >  The use of SSM framework, impossible to execute SQL statements
The use of SSM framework, impossible to execute SQL statements

Time:09-21

16:37:19. [HTTP - nio - 8080-948 the exec - 9] the DEBUG org. Mybatis. Spring. SqlSessionUtils - Creating a new SqlSession
16:37:19. [HTTP - nio - 8080-959 the exec - 9] the DEBUG org. Mybatis. Spring. SqlSessionUtils - SqlSession [org. Apache. Ibatis. Session. Defaults. DefaultSqlSession @ 3317 ea24] was not registered for synchronization because synchronization is not active
16:37:19. [HTTP - nio - 8080-971 the exec - 9] the DEBUG org. Mybatis. Spring. SqlSessionUtils - Closing non transactional SqlSession [org. Apache. Ibatis. Session. Defaults. DefaultSqlSession @ 3317 ea24]

After writing the code, the code without error, but shows the SQL transaction no, while performing the login is also appeared but when using a select statement in the code will handle affairs or run successfully, I'm calling the other a statement will appear when the insert statement above three sentences show the transaction are not synchronized, my two SQL statements is operating in different tables, there is no error code, very helpless, don't know where no,




Call the above SQL statement omitted some dao class service class
IUserService. Insertwu (wu);

CodePudding user response:

Look at things in the spring configuration file control layer service path write wrong not

CodePudding user response:

1 see SQL related configuration have wrong
2 put the SQL statements in database operation to see have baa problem
3 look at the values have baa problem

Sometimes is a careless, is unlikely to be related or data to the result of what went wrong, is not necessarily the SQL language has a problem

CodePudding user response:

SQL statement to not have a problem, to get the value of the small program in SSM background are received and output a success, but the output seems to be more a item_id=0, but I don't have database item_id=0, the value of the other item_id, should not affect his insert,
This is the way to the service
Public Map Insertwu Wu (Wu) {
Return iUserDao. Insertwu (wu);
}
This is the dao methods
@ Override
Public Map Insertwu Wu (Wu) {
Try {
Return this. UserDao. Insertwu (wu);
} the catch (Exception e) {
e.printStackTrace();
}
Return (Map) Wu;
}

CodePudding user response:

CodePudding user response:

Insert (Wu) method to add a transaction try, error message you, the transaction has not been activated

CodePudding user response:

Stick your XML configuration of Mybatis out have a look at your service implementation method of the insert

CodePudding user response:

Spring - mybastic XML file
<? The XML version="1.0" encoding="utf-8"?>
XMLNS: xsi="http://www.w3.org/2001/XMLSchema-instance"
XMLNS: context="http://www.springframework.org/schema/context"
XMLNS: tx="http://www.springframework.org/schema/tx"
Xsi: schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd "& gt;










nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related