Implementation of mybatis Oracle autoincrement sequence

The code of mybatis Oracle autoincrement sequence is as follows:

Resulttype = "int" returns an int type

Keyproperty assigns the return value to the property of the object in the parametertype, that is, s in the xxxxx class_ ID attribute

Returns the sequence ID, which can be left blank if not required

Let's take a look at mybatis configuring the self growth of Oracle's primary key

Mysql, sqlserver and other databases have their own primary key self growth, such as auto_ The function of increment can be used directly

Usegeneratedkeys = "true", such as the following configuration

Oracle cannot. The self growth of Oracle primary key is realized through sequence, so this method is not allowed. You need to use:

1. First find out the ID through sequence, and then insert it

2. Directly insert sequence Nextval, as follows

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>