JPA使用ORACL数据库的实体配置

@Entity
@Table(name = "t_st_rolewebmenu")
@SequenceGenerator(name = "ID_SEQ", sequenceName = "ROLEANDMENU_SEQ", allocationSize = 1)
public class RoleAndMenu {
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ID_SEQ")
    private Long id;
    private Long emsRoleId;
    private Long emsMenuId;

}

其中sequenceName = "ROLEANDMENU_SEQ" 的值我是每个实体起一个名字  具体我也没细研究

这样就实现了ORACL数据库主键ID 从1自增长

你可能感兴趣的:(JPA)