Hibernate Annotation Placement Question

后端 未结 5 1620
离开以前
离开以前 2020-12-01 00:41

I\'ve got what I think is a simple question. I\'ve seen examples both ways. The question is - \"why can\'t I place my annotations on the field?\". Let me give you an exam

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-01 01:12

    Does it work if you do the following:

    @Entity
    @Table(name="widget")
    public class Widget {
        @Id
        @GeneratedValue(strategy=GenerationType.AUTO)
    
        private Integer id;
    
        public Integer getId() { return this.id; }
        public Integer setId(Integer Id) { this.id = id;}
    }
    

提交回复
热议问题