one, for the table to create a self-growth from the paragraph there are two, one is different tables using their own sequence , the following methods:
1, in Oracle sequence first create sequence
Create sequence Seq_idminvalue 1start with 1increment by 1cache 20;
2, the configuration in your Hbm.xml
seq_id
When you insert the data again, Hibernate automatically generates the following statement:
Hibernate:select Seq_id.nextval from dual Hibernate:insert into YXJK. T_YXJK_WHRYTXL (XM0000, ZW0000, LXDH00, SJHM00, dzyj00,ip0000, ID0000) VALUES (?) , ? , ? , ? , ? , ? , ? )
Automatically generates the next sequence value, and then inserts the object into the table. When used, it is important to note that the requirement for the primary key of the sequence is Shor,long, or integer hibernate.
Second, there is a way to use the public sequence, which can not specify the table to use the sequence, then the corresponding hbm.xml content is:
Then create a common sequence object named Hibernate_sequence
Create Sequence hibernate_sequence
MinValue 0
MaxValue 99999999
Start with 10000
Increment by 1 ;
three, considerations
If the database is ported from other databases, such as SQL Server, the starting value for creating the sequence should be larger than the largest ID value in the current table, otherwise an error occurs because sequence does not maintain that the existing values are duplicated before the library.
1, sequence: for Oracle database
Sequence name
2, native: used across databases, generated by the underlying dialect.
Default.sequence to hibernate_sequence
Note: Hibernate will find the hibernate_sequence sequence in Oracle by default when using native. If the sequence is not in Oracle, an error will be encountered even with the Oracle database.