When the dao interface defines the save method, try to modify the return type to String to see if it is received. The default is to return the number of affected rows. If selectKey is configured, the content of selectKey may be returned.
When using MyBatis as the persistence layer, the insert statement does not return the primary key value of the record by default, but returns the number of inserted records; if the business layer needs to obtain the primary key of the record, this function can be completed through configuration
For the Sequence primary key, you must specify a primary key value for the record to be inserted before executing insert sql, such as Oracle and DB2. You can use the following configuration method:
Mybatis returns the number of affected rows by default. To return the ID, you need to write it separately. If it is an oracle database, uuid can be written as sys_guid()
If it is mysql, it must be the same as mentioned above, give an ID first and then save it
Before calling the persistence layer, generate a UUID yourself, put it in the object and the method returns the UUID.
When the dao interface defines the save method, try to modify the return type to String to see if it is received.
The default is to return the number of affected rows. If selectKey is configured, the content of selectKey may be returned.
When using MyBatis as the persistence layer, the insert statement does not return the primary key value of the record by default, but returns the number of inserted records; if the business layer needs to obtain the primary key of the record, this function can be completed through configuration
For the Sequence primary key, you must specify a primary key value for the record to be inserted before executing insert sql, such as Oracle and DB2. You can use the following configuration method:
Mybatis returns the number of affected rows by default. To return the ID, you need to write it separately.
If it is an oracle database, uuid can be written as sys_guid()
If it is mysql, it must be the same as mentioned above, give an ID first and then save it
There is no need to generate a uuid in advance in the code. This problem can be solved by understanding the keyProperty attribute in selectKey.
In this way, when selectKey is generated, the generated UUID will be set into the current object