spring+hibernate mapping class without xml

前端 未结 4 1148
不知归路
不知归路 2021-02-03 10:58

in my applicationContext.xml, this is how I map xml to POJO. how to map directory to class file without required to create xml?



        
4条回答
  •  野的像风
    2021-02-03 11:59

    @Pascal Thivent gives a very good start to what you want to do. For each Entity class you will need to annotate them. This is the docs that expalin the annotations in Hibernate.

    e.g. From the docs:

       @Entity
      public class Flight implements Serializable {
        Long id;
    
        @Id
        public Long getId() { return id; }
    
        public void setId(Long id) { this.id = id; }
      }
    

    So in addition to what was mentioned by @Pascal Thivent you should get everything you need.

提交回复
热议问题