物业访问。吸气的逻辑

时间:2012-03-12 12:48:21

标签: java hibernate jpa

ObjectID是我自己的ID级

在我映射的Entity-class中,我有ID的下一个getter

   @Id
   @Column(name = "aa_id")
   @SequenceGenerator(name = "PatientSequenceGenerator",
                      sequenceName = "patient_seq")
   @GeneratedValue(strategy = GenerationType.SEQUENCE,
                   generator = "PatientSequenceGenerator")
   public ObjectID getId()
   {
      return id;
   }  

生成器生成Long值,所以我得到了异常

this id generator generates long, integer, short or string  

那么,我是否可以添加到我的getter逻辑中,这将从long创建ObjectID,例如

//annotations
    public ObjectID getId()
           {  
//logic that that get Long from sequance
              return new ObjectID(gettedLong);
           }  

1 个答案:

答案 0 :(得分:2)

你不应该这样做。您的ID字段应为列出的类型之一,或@EmbeddedId@IdClass