14 criteria api

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

description

 

Transcript of 14 criteria api

Page 1: 14 criteria api

Professional Open Source™

© JBoss, Inc. 2003, 2004. 1

07/17/04

Criteria API

Page 2: 14 criteria api

© JBoss, Inc. 2003, 2004. 2

Professional Open Source™

Page 3: 14 criteria api

© JBoss, Inc. 2003, 2004. 3

Professional Open Source™

Using Restrictions

from Book book where name='Hibernate Quickly'

Page 4: 14 criteria api

© JBoss, Inc. 2003, 2004. 4

Professional Open Source™

Getting Unique Result

For Ignoring case

Page 5: 14 criteria api

© JBoss, Inc. 2003, 2004. 5

Professional Open Source™

Page 6: 14 criteria api

© JBoss, Inc. 2003, 2004. 6

Professional Open Source™

Same as

Page 7: 14 criteria api

© 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

Page 8: 14 criteria api

© JBoss, Inc. 2003, 2004. 8

Professional Open Source™

Projections

Same as

Page 9: 14 criteria api

© JBoss, Inc. 2003, 2004. 9

Professional Open Source™

Same as

Page 10: 14 criteria api

© JBoss, Inc. 2003, 2004. 10

Professional Open Source™

Same as

Page 11: 14 criteria api

© JBoss, Inc. 2003, 2004. 11

Professional Open Source™

Grouping

Page 12: 14 criteria api

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