Professional Open Source™




           Criteria API




© JBoss, Inc. 2003, 2004.                    07/17/04   1
Professional Open Source™




© JBoss, Inc. 2003, 2004.                               2
Using Restrictions
                                                Professional Open Source™




    from Book book where name='Hibernate Quickly'




© JBoss, Inc. 2003, 2004.                                                   3
Getting Unique Result
                               Professional Open Source™




         For Ignoring case




© JBoss, Inc. 2003, 2004.                                  4
Professional Open Source™




© JBoss, Inc. 2003, 2004.                               5
Professional Open Source™




        Same as




© JBoss, Inc. 2003, 2004.                               6
Match modes
                                                         Professional Open Source™


  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.                                                            7
Projections
                            Professional Open Source™




         Same as




© JBoss, Inc. 2003, 2004.                               8
Professional Open Source™




                            Same as




© JBoss, Inc. 2003, 2004.                                         9
Professional Open Source™




                            Same as




© JBoss, Inc. 2003, 2004.                                         10
Grouping
                            Professional Open Source™




© JBoss, Inc. 2003, 2004.                               11
Using Detached Criteria
                                                           Professional Open Source™


  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:




© JBoss, Inc. 2003, 2004.                                                              12

14 criteria api

  • 1.
    Professional Open Source™ Criteria API © JBoss, Inc. 2003, 2004. 07/17/04 1
  • 2.
    Professional Open Source™ ©JBoss, Inc. 2003, 2004. 2
  • 3.
    Using Restrictions Professional Open Source™ from Book book where name='Hibernate Quickly' © JBoss, Inc. 2003, 2004. 3
  • 4.
    Getting Unique Result Professional Open Source™ For Ignoring case © JBoss, Inc. 2003, 2004. 4
  • 5.
    Professional Open Source™ ©JBoss, Inc. 2003, 2004. 5
  • 6.
    Professional Open Source™ Same as © JBoss, Inc. 2003, 2004. 6
  • 7.
    Match modes Professional Open Source™  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. 7
  • 8.
    Projections Professional Open Source™ Same as © JBoss, Inc. 2003, 2004. 8
  • 9.
    Professional Open Source™ Same as © JBoss, Inc. 2003, 2004. 9
  • 10.
    Professional Open Source™ Same as © JBoss, Inc. 2003, 2004. 10
  • 11.
    Grouping Professional Open Source™ © JBoss, Inc. 2003, 2004. 11
  • 12.
    Using Detached Criteria Professional Open Source™  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: © JBoss, Inc. 2003, 2004. 12