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.