sequence:s_author_id,从1开始步幅是1,最大值是999999999
-- Create sequence create sequence S_AUTHOR_ID minvalue 1 maxvalue 999999999 start with 1 increment by 1 cache 20;
触发器:trg_authors
create or replace trigger trg_authors before insert on reader_resource_author for each row begin select s_author_id.nextval into :new.author_id from dual; end;
java代码entity:
@Entity @javax.persistence.SequenceGenerator( name = "authorid", sequenceName="s_author_id" ) @Table(name = "reader_resource_author") public class ResourceAuthor extends PersistentObject{ @Id @GeneratedValue(strategy=GenerationType.SEQUENCE,generator="authorid") @Column(name = "author_id") public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } }