Automatically executes select last_insert_id () after inserting data in Hibernate JPA () _oracle

Source: Internet
Author: User

Today I had a problem with the project, which was not noticed before. I'm using the spring mvc+ Hibernate JPA + MySQL database. A single SELECT statement is added to the SQL execution log after inserting data:

Copy Code code as follows:

Hibernate:insert into Click_statstic (logdate, memoid, SRC, typeid) VALUES (?,?,?,?)
Hibernate:select last_insert_id ()

A primary key in a table is a self-added column. However, in the past projects, no such problems have been found. So all kinds of search on the Internet can not find the reason. I thought it might be a configuration problem.

This configuration was finally found in the Persistence.xml configuration file:

Copy Code code as follows:

<property name= "Hibernate.temp.use_jdbc_metadata_defaults" value= "false"/>

Deleting this configuration does not have an extra SELECT statement. The exact reason and the purpose of doing so are unknown. If you have friends who know, please share ~ Thank you.

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.