开发者

Design question

We are building software in java, and are new to it. I confused about JPA. Normally in MVC pattern, SQL queries are hidden in model. And controller can't access the d开发者_JAVA百科b directly.

When I use JPA, should model retrieve JPA object to controller? If yes, then controller has access to db, and this is against to pattern?


JPA is just an abstraction between your Domain Model Object and SQL (your JPA implementation like Hibernate etc. creates all the SQL queries for you).

The controller will not even know which database JPA uses at all. If you want a simpler application architecture your controller can use the JPA features directly. Other architecture use a Data Acces Object layer (where these objects provide methods like List getAllThingsBetween(Date from, Date to)) between your controller and JPA, so that the controller won't even know, that you are using JPA.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜