我想使用注释指定以下hbm配置:
<id name="somePK" column=""somePK"" type="long"> <generator class="com.db.hibernate.KeyGenerator"/> </id>
我不确定如何使用
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SEQ_STORE")
我必须@javax.persistence.SequenceGenerator在每个实体类中指定吗? 我可以仅在@GeneratedValue注释下指定类名称吗?
@javax.persistence.SequenceGenerator
@GeneratedValue
请找到以下我在项目中使用过的相同代码集。
@Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "XyzIdGenerator") @GenericGenerator(name = "XyzIdGenerator", strategy = "com.mycompany.myapp.id.BigIntegerSequenceGenerator", parameters = { @Parameter(name = "sequence", value = "xyz_id_sequence") }) public BigInteger getId() { return id; } package com.mycompany.myapp.id; import org.hibernate.id.SequenceGenerator; ... public class BigIntegerSequenceGenerator extends SequenceGenerator { @Override public Serializable generate(SessionImplementor session, Object obj) { ... } }