What is the difference between criteria and detached criteria? When should we go for criteria and when should we go for detached criteria?
What is the difference between criteria and detached criteria? When should we go for
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The detached criteria allows you to create the query without
Session. Then you can execute the search in an arbitrary session.In fact you should think carefully when using a
detached criteriausing another, or a new, session (no cache, and creation of the session).They are most useful for join conditions, subselects, and to query outside the current session.
Another common use is for code reuse. Many developers declare them as
staticqueries and execute them using the underlying session from differentDAO.