Solve the Problem of automatically executing select last_insert_id () after insert data in Hibernate JPA ()

Source: Internet
Author: User

I encountered a problem in my project today, but I didn't pay attention to it before. I am using Spring MVC + Hibernate JPA + MySQL database. After data is inserted, an additional select statement is displayed in the SQL Execution log:
Copy codeThe Code is as follows:
Hibernate: insert into click_statstic (logDate, memoId, src, typeId) values (?, ?, ?, ?)
Hibernate: select last_insert_id ()

The table has an auto-incrementing primary key. However, this problem was not found in previous projects. Therefore, I cannot find the cause on the Internet. It may be a configuration problem.

Finally, the following configuration is found in the persistence. xml configuration file:
Copy codeThe Code is as follows:
<Property name = "hibernate. temp. use_jdbc_metadata_defaults" value = "false"/>

If you delete this configuration, no additional select statements are available. The specific reasons and the purpose of doing so are unknown. If you know something, share it with me ~ Thank you.

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.