Citation Link: http://blog.csdn.net/w183705952/article/details/7367272
How hibernate grows with IDs in Oracle
The first: The growth strategy for setting the ID is sequence, specifying sequence's name, preferably a sequence for each table, as is the case with automatic growth in ms-sql,my-sql, without the need to create a trigger, The specific Oracle database scripts and hibernate configuration files are as follows:
[1]oracle creation script for data tables:
Java code
CREATE TABLE DEPARTMENT (
ID number (0) DEFAULT ' 0 ' not NULL,
NAME VARCHAR2 (255) is not NULL,
DESCRIPTION CLOB
);
ALTER TABLE DEPARTMENT ADD CONSTRAINT primary_0 PRIMARY KEY (ID) ENABLE;
ALTER TABLE DEPARTMENT ADD CONSTRAINT uk_department_1 UNIQUE (NAME);
CREATE SEQUENCE department_id_seq MINVALUE 10000 MAXVALUE 999999999999999999999999 INCREMENT by 1 nocycle;
Create a department table and create a separate sequence for the department table with the name Sequence_id_seq, and you do not need to create a trigger.
[Configuration of the 2]hibernate mapping file:
Java code
<?xml version= "1.0"?>
<! DOCTYPE hibernate-mapping Public
"-//hibernate/hibernate Mapping DTD 3.0//en"
"Http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
="Com.liyanframework.demo.domain" >
<class name="Department" table="Department" >
<id name="id" column="id" >
<generator Class="sequence" >
<param name="sequence" >DEPARTMENT_ID_SEQ</param>
</generator>
</id>
<property name="name" column="name" type="string"/>
<property name="description" column="description" type="text"/>
</class>
How hibernate grows with IDs in Oracle