MyBatis (Oracle) How to use the primary key automatically plus 1 when insert

Source: Internet
Author: User

<insert id= "Insert" paramtype= "User" >

<seleckey keyproperty= "id" order= "before" resulttype= "int" >

Select User_sequence.nextval Form Dual

</selectKey>

</insert>

The above attributes describe:

keyproperty= "id": a property in a class

Order: Build Policy: (insert into before or after execution): default is After execution

Sequence in the User_sequence:oracle
To create a sequence:

Create sequence User_sequence

Start with 1

Increment by 1

Nomaxvalue

MinValue 1

Nocycle

Cache 10;

MyBatis (Oracle) How to use the primary key automatically plus 1 when insert

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.