• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jpa NamedQueries position debate

 
Sharon whipple
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have Manager -> Dao -> entityBean;
Where will be more appropriate to put the NamedQuery's, on the entity or on the Dao Implementation?
Currently all NamedQueries are in the Entity Beans like :



Thank you
Sharon
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personally, I like them on the Entity objects.

Mark
 
Sharon whipple
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any reason
?
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you need to have them on an object that is consumed by the AnnotationConfiguration object during initialization. You don't generally feed DAO's to the Hibernate Configuration object, although it is a must with any JPA annotated POJO.

You suggested entities or DAOs. What about a third type, maybe a class that does nothing else other than hold named queries?

You know, you could totally eliminate the discussion by using the Criteria API.

-Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic