日期:2014-05-19 浏览次数:20742 次
//JPA 基类的标识 @MappedSuperclass public abstract class PkidEntity { /** * 主键及主键生成方式 */ @Id @GenericGenerator(name="hibernate-uuid",strategy="uuid") @GeneratedValue(generator="hibernate-uuid") @Column(name="pkid", nullable=false) protected String pkid; public String getPkid() { return pkid; } public void setPkid(String pkid) { this.pkid = pkid; } }
@MappedSuperclass public abstract class IdEntity { protected Long id; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PKGen") @SequenceGenerator(name = "PKGen", sequenceName = "HIBERNATE_SEQUENCE", allocationSize = 1) public Long getId() { return id; } public void setId(Long id) { this.id = id; } }
@Id @GeneratedValue(generator = "system-uuid") @GenericGenerator(name = "system-uuid", strategy = "uuid") public String getId() { return this.id; } public void setId(String id) { this.id = id; }
------解决方案--------------------
看了下,原来你是用ORACLE数据库的序列自增的,你就用@SequenceGenerator
------解决方案--------------------