14 criteria api
-
Upload
thirumuru2012 -
Category
Technology
-
view
212 -
download
0
description
Transcript of 14 criteria api
Professional Open Source™
© JBoss, Inc. 2003, 2004. 1
07/17/04
Criteria API
© JBoss, Inc. 2003, 2004. 2
Professional Open Source™
© JBoss, Inc. 2003, 2004. 3
Professional Open Source™
Using Restrictions
from Book book where name='Hibernate Quickly'
© JBoss, Inc. 2003, 2004. 4
Professional Open Source™
Getting Unique Result
For Ignoring case
© JBoss, Inc. 2003, 2004. 5
Professional Open Source™
© JBoss, Inc. 2003, 2004. 6
Professional Open Source™
Same as
© JBoss, Inc. 2003, 2004. 7
Professional Open Source™
Match modes
If you want to search using wildcards, you can use the MatchMode class
The following MatchMode values are available:
• START: Matches the start of the string with the pattern• END: Matches the end of the string with the pattern• ANYWHERE: Matches the pattern anywhere in the string• EXACT: Matches the complete pattern in the string
© JBoss, Inc. 2003, 2004. 8
Professional Open Source™
Projections
Same as
© JBoss, Inc. 2003, 2004. 9
Professional Open Source™
Same as
© JBoss, Inc. 2003, 2004. 10
Professional Open Source™
Same as
© JBoss, Inc. 2003, 2004. 11
Professional Open Source™
Grouping
© JBoss, Inc. 2003, 2004. 12
Professional Open Source™
Using Detached Criteria
If you don’t have an open session, you can instantiate a detached criteria by using the DetachedCriteria. forClass() method and later attach it to a session for execution.
When you have a session to run the query, you call getExecutableCriteria() and pass the session as a method argument. The getExecutableCriteria() method returns an executable instance of criteria: