Mixing JPA annotations and XML configuration

前端 未结 3 1306
萌比男神i
萌比男神i 2021-01-14 17:44

I have a fairly large (new) project in which we have annotated many domain classes with JPA mappings. Now it is time to implement many named queries -- some entities may ha

3条回答
  •  感动是毒
    2021-01-14 18:20

    It's possible, but I don't think it's needed. I work on a lot of big projects with many named queries attached to some entities and I don't think that this clutters the source much - after all the queries are all before the class definition. The main advantage of using annotations is that you can see everything in the source. If you've extracted the queries in an xml config the presence of the named queries won't be immediately visible which I'd consider a drawback. I like to keep stuff pure - either xml only setup or only annotations setup. The only xml config I generally keep around on JPA projects in the persistence.xml.

提交回复
热议问题