如何生成具有自动休眠ID与初始值产生 [英] How to generate a hibernate ID with auto generate with a starting value
本文介绍了如何生成具有自动休眠ID与初始值产生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我已经写了code这样的
@Id
@Column(可空= FALSE)
@GeneratedValue(策略= GenerationType.AUTO)
公众诠释getUserID(){
返回用户名;
}
块引用>但我手动从DAO,如设置为e.setUserID(01);到insert.Otherwise排不插入有任何过程中获得的价值为ID和检索自动生成什么样的价值。即时通讯思想我会得到一些帮助。
解决方案使用
@GenericGenerator(NAME =发电机,战略=增量)
@GeneratedValue(发电机=发电机)Hi I have written code like this
@Id @Column(nullable=false) @GeneratedValue(strategy=GenerationType.AUTO) public int getUserID() { return UserID; }
But I manually setting it from DAO like "e.setUserID(01);" to insert.Otherwise row not inserting Is there any process to get value to id and retrieve what value generated automatically. Im thinking i will get some help
解决方案Use
@GenericGenerator(name="generator", strategy="increment") @GeneratedValue(generator="generator")
这篇关于如何生成具有自动休眠ID与初始值产生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文