主键生成策略采用sequence,但没有指定具体的sequence的时候,Hibernate会访问一个默认的sequence,是hibernate_sequence,我们也需要在数据库中建立这个sequence
xml文件配置,采用默认seq
<id name="pkId" type="java.math.BigDecimal"> <column name="PK_ID" precision="22" scale="0" /> <generator class="sequence" /> </id>
<generator class="sequence" > <param name="sequence">seq_t_user</param> </generator>
@SequenceGenerator (name = "SEQ", sequenceName = "SEQ_T_CMP_CITY", allocationSize = 1) @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ") @Column(name = "id") public Integer getId() { return id ; }
hibernate主键生成策略值sequence,布布扣,bubuko.com
原文地址:http://blog.csdn.net/shanhuhau/article/details/24978253