hibernate - Where should I write my criteria queries in a Grails Project ? In the Service layer or in the Domain Models? -


I am currently working on a Grails project and I have to write some questions using the Hibernate criteria.

Where and Why Should I Write Hibernate Criteria Questions?

Is this service level? Or would it be a better idea to avoid the anemic domain model and to write the named questions there? Or, should I create a separate layer under the service layer?

A short answer is " it depends ".

The long answer is " It depends on how you are structuring your application ".

If you plan to employ everything at a service level, then a service level is a good place to keep your questions.

If you plan to use the same question from multiple services or chaining, then they understand more than the named queries on the domain class.

Therefore, "it depends" how your app is designed. Either there is an acceptable place to put questions, as long as it meets your needs and facilitates the code reuse.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -