[color=darkred]1.建库[/color]
drop table MESSAGE_INFO
create table MESSAGE_INFO
(
ID NUMBER(10) not null,
TITLE VARCHAR2(100) not null,
CONTENT VARCHAR2(1000) not null,
TYPE VARCHAR2(20) not null,
SCOPE VARCHAR2(100),
CREATETIME NUMBER(14) not null,
EXPIRETIME NUMBER(14) not null,
MEMO VARCHAR2(200),
constraint PK_MESSAGE_INFO primary key (ID)
)
[color=darkred]2.建序列sequence[/color]
drop sequence SEQ_MESSAGE_INFO
create sequence SEQ_MESSAGE_INFO
minvalue 1
maxvalue 999999999999999999999999999
start with 1
increment by 1
cache 100
[color=darkred]3.建触发器trigger[/color]
create or replace trigger TRI_MESSAGE_INFO
before insert on MESSAGE_INFO
for each row
begin
select SEQ_MESSAGE_INFO.nextval into:new.id from sys.dual;
end;
[color=darkred]4.实体类MESSAGE_INFO配置[/color]
@Id
@SequenceGenerator(name="MESSAGE_INFO_GENERATOR",sequenceName="SEQ_MESSAGE_INFO",allocationSize=1)
@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="MESSAGE_INFO_GENERATOR")
private Long id;//主键id
drop table MESSAGE_INFO
create table MESSAGE_INFO
(
ID NUMBER(10) not null,
TITLE VARCHAR2(100) not null,
CONTENT VARCHAR2(1000) not null,
TYPE VARCHAR2(20) not null,
SCOPE VARCHAR2(100),
CREATETIME NUMBER(14) not null,
EXPIRETIME NUMBER(14) not null,
MEMO VARCHAR2(200),
constraint PK_MESSAGE_INFO primary key (ID)
)
[color=darkred]2.建序列sequence[/color]
drop sequence SEQ_MESSAGE_INFO
create sequence SEQ_MESSAGE_INFO
minvalue 1
maxvalue 999999999999999999999999999
start with 1
increment by 1
cache 100
[color=darkred]3.建触发器trigger[/color]
create or replace trigger TRI_MESSAGE_INFO
before insert on MESSAGE_INFO
for each row
begin
select SEQ_MESSAGE_INFO.nextval into:new.id from sys.dual;
end;
[color=darkred]4.实体类MESSAGE_INFO配置[/color]
@Id
@SequenceGenerator(name="MESSAGE_INFO_GENERATOR",sequenceName="SEQ_MESSAGE_INFO",allocationSize=1)
@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="MESSAGE_INFO_GENERATOR")
private Long id;//主键id