The younger brother recently encountered a question when you do a project is the configuration of the self-growth field in Hibernate, not self-growth primary key. After the unremitting efforts of the younger brother, finally, listen to the younger brother slowly:
In fact, it is very simple to set the self-growth field to the primary key in the configuration file.
example:
Database structure:
ID INT has grown, step size is 1
Nickname Varchar PRIMARY Key
How does the Hibernate object write me? Below is the configuration file:
XML Version = "1.0" encoding = "UTF-8"?>
id>
clas>
hibernate-maping>
The above is configured to run on the SQL2000.
In fact, there are many ways to deal with this situation, and the generated key mode is a good way, the younger brother is in order to lazy, I want to have such a dirt-of-Chinese method ^ _ ^. If you have any wrong places, please ask your guidance.
QQ: 316853067