public class Human {
private Integer id;
private String names;
public Integer getId() {
return id;
}
public String getNames() {
return names;
}
public void setId(Integer id) {
this.id = id;
}
public void setNames(String names) {
this.names = names;
}
}
create table Human (id varchar2(10),names varchar2(20)) tablespace test_data
这是建表
create sequence mysequence
increment by 1
start with 10000
nomaxvalue
nocycle
nocache
这是在oracle中建立sequence
ass name="com.ronaldo.Entity.Human" table="HUMAN" schema="SYSTEM">
<id name="id" type="java.lang.Integer" column="ID">
<generator class="sequence">
<param name="sequence">mysequence</param>
</generator>
</id>
hibernate的配置如上,使用oracle中的mysequence
成功后会在后台打印出:
Hibernate: select mysequence.nextval from dual
Hibernate: insert into SYSTEM.HUMAN (NAMES, ID) values (?, ?)