hibernate主键生成策略值sequence

主键生成策略采用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>

采用指定eeq

<generator class="sequence" >
            	<param name="sequence">seq_t_user</param>
</generator>

注解配置seq

@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

hibernate主键生成策略值sequence

上一篇:《linux 内核完全剖析》 void free_page() 分析


下一篇:初接触Linux,LVM的备份