码迷,mamicode.com
首页 > 系统相关 > 详细

hibernate主键生成策略值sequence

时间:2014-05-04 18:01:18      阅读:330      评论:0      收藏:0      [点我收藏+]

标签: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

标签:hibernate sequence

原文地址:http://blog.csdn.net/shanhuhau/article/details/24978253

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!