Java Doc for Criteria.java in  » Database-ORM » hibernate » org » hibernate » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database ORM » hibernate » org.hibernate 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.hibernate.Criteria

All known Subclasses:   org.hibernate.impl.CriteriaImpl,
Criteria
public interface Criteria extends CriteriaSpecification(Code)
Criteria is a simplified API for retrieving entities by composing Criterion objects. This is a very convenient approach for functionality like "search" screens where there is a variable number of conditions to be placed upon the result set.

The Session is a factory for Criteria. Criterion instances are usually obtained via the factory methods on Restrictions. eg.
 List cats = session.createCriteria(Cat.class)
 .add( Restrictions.like("name", "Iz%") )
 .add( Restrictions.gt( "weight", new Float(minWeight) ) )
 .addOrder( Order.asc("age") )
 .list();
 
You may navigate associations using createAlias() or createCriteria().
 List cats = session.createCriteria(Cat.class)
 .createCriteria("kittens")
 .add( Restrictions.like("name", "Iz%") )
 .list();
 
 List cats = session.createCriteria(Cat.class)
 .createAlias("kittens", "kit")
 .add( Restrictions.like("kit.name", "Iz%") )
 .list();
 
You may specify projection and aggregation using Projection instances obtained via the factory methods on Projections.
 List cats = session.createCriteria(Cat.class)
 .setProjection( Projections.projectionList()
 .add( Projections.rowCount() )
 .add( Projections.avg("weight") )
 .add( Projections.max("weight") )
 .add( Projections.min("weight") )
 .add( Projections.groupProperty("color") )
 )
 .addOrder( Order.asc("color") )
 .list();
 

See Also:   Session.createCriteria(java.lang.Class)
See Also:   org.hibernate.criterion.Restrictions
See Also:   org.hibernate.criterion.Projections
See Also:   org.hibernate.criterion.Order
See Also:   org.hibernate.criterion.Criterion
See Also:   org.hibernate.criterion.Projection
See Also:   org.hibernate.criterion.DetachedCriteria
See Also:    a disconnected version of this API
author:
   Gavin King




Method Summary
public  Criteriaadd(Criterion criterion)
     Add a Criterion restriction to constrain the results to be retrieved.
Parameters:
  criterion - The Criterion criterion object representing therestriction to be applied.
public  CriteriaaddOrder(Order order)
     Add an Order ordering to the result set.
Parameters:
  order - The Order order object representing an orderingto be applied to the results.
public  CriteriacreateAlias(String associationPath, String alias)
     Join an association, assigning an alias to the joined association.

Functionally equivalent to Criteria.createAlias(String,String,int) using Criteria.INNER_JOIN for the joinType.
Parameters:
  associationPath - A dot-seperated property path
Parameters:
  alias - The alias to assign to the joined association (for later reference).

public  CriteriacreateAlias(String associationPath, String alias, int joinType)
     Join an association using the specified join-type, assigning an alias to the joined association.

The joinType is expected to be one of Criteria.INNER_JOIN (the default), Criteria.FULL_JOIN , or Criteria.LEFT_JOIN .
Parameters:
  associationPath - A dot-seperated property path
Parameters:
  alias - The alias to assign to the joined association (for later reference).
Parameters:
  joinType - The type of join to use.

public  CriteriacreateCriteria(String associationPath)
     Create a new Criteria, "rooted" at the associated entity.
public  CriteriacreateCriteria(String associationPath, int joinType)
     Create a new Criteria, "rooted" at the associated entity, using the specified join type.
Parameters:
  associationPath - A dot-seperated property path
Parameters:
  joinType - The type of join to use.
public  CriteriacreateCriteria(String associationPath, String alias)
     Create a new Criteria, "rooted" at the associated entity, assigning the given alias.

Functionally equivalent to Criteria.createCriteria(String,String,int) using Criteria.INNER_JOIN for the joinType.
Parameters:
  associationPath - A dot-seperated property path
Parameters:
  alias - The alias to assign to the joined association (for later reference).

public  CriteriacreateCriteria(String associationPath, String alias, int joinType)
     Create a new Criteria, "rooted" at the associated entity, assigning the given alias and using the specified join type.
Parameters:
  associationPath - A dot-seperated property path
Parameters:
  alias - The alias to assign to the joined association (for later reference).
Parameters:
  joinType - The type of join to use.
public  StringgetAlias()
     Get the alias of the entity encapsulated by this criteria instance.
public  Listlist()
     Get the results.
public  ScrollableResultsscroll()
    
public  ScrollableResultsscroll(ScrollMode scrollMode)
     Get the results as an instance of ScrollableResults based on the given scroll mode.
Parameters:
  scrollMode - Indicates the type of underlying database cursor torequest.
public  CriteriasetCacheMode(CacheMode cacheMode)
     Override the cache mode for this particular query.
Parameters:
  cacheMode - The cache mode to use.
public  CriteriasetCacheRegion(String cacheRegion)
     Set the name of the cache region to use for query result caching.
public  CriteriasetCacheable(boolean cacheable)
     Enable caching of this query result, provided query caching is enabled for the underlying session factory.
Parameters:
  cacheable - Should the result be considered cacheable; default isto not cache (false).
public  CriteriasetComment(String comment)
     Add a comment to the generated SQL.
public  CriteriasetFetchMode(String associationPath, FetchMode mode)
     Specify an association fetching strategy for an association or a collection of values.
public  CriteriasetFetchSize(int fetchSize)
     Set a fetch size for the underlying JDBC query.
public  CriteriasetFirstResult(int firstResult)
     Set the first result to be retrieved.
public  CriteriasetFlushMode(FlushMode flushMode)
     Override the flush mode for this particular query.
Parameters:
  flushMode - The flush mode to use.
public  CriteriasetLockMode(LockMode lockMode)
    
public  CriteriasetLockMode(String alias, LockMode lockMode)
    
public  CriteriasetMaxResults(int maxResults)
     Set a limit upon the number of objects to be retrieved.
public  CriteriasetProjection(Projection projection)
     Used to specify that the query results will be a projection (scalar in nature).
public  CriteriasetResultTransformer(ResultTransformer resultTransformer)
     Set a strategy for handling the query results.
public  CriteriasetTimeout(int timeout)
     Set a timeout for the underlying JDBC query.
Parameters:
  timeout - The timeout value to apply.
public  ObjectuniqueResult()
     Convenience method to return a single instance that matches the query, or null if the query returns no results.



Method Detail
add
public Criteria add(Criterion criterion)(Code)
Add a Criterion restriction to constrain the results to be retrieved.
Parameters:
  criterion - The Criterion criterion object representing therestriction to be applied. this (for method chaining)



addOrder
public Criteria addOrder(Order order)(Code)
Add an Order ordering to the result set.
Parameters:
  order - The Order order object representing an orderingto be applied to the results. this (for method chaining)



createAlias
public Criteria createAlias(String associationPath, String alias) throws HibernateException(Code)
Join an association, assigning an alias to the joined association.

Functionally equivalent to Criteria.createAlias(String,String,int) using Criteria.INNER_JOIN for the joinType.
Parameters:
  associationPath - A dot-seperated property path
Parameters:
  alias - The alias to assign to the joined association (for later reference). this (for method chaining)




createAlias
public Criteria createAlias(String associationPath, String alias, int joinType) throws HibernateException(Code)
Join an association using the specified join-type, assigning an alias to the joined association.

The joinType is expected to be one of Criteria.INNER_JOIN (the default), Criteria.FULL_JOIN , or Criteria.LEFT_JOIN .
Parameters:
  associationPath - A dot-seperated property path
Parameters:
  alias - The alias to assign to the joined association (for later reference).
Parameters:
  joinType - The type of join to use. this (for method chaining)




createCriteria
public Criteria createCriteria(String associationPath) throws HibernateException(Code)
Create a new Criteria, "rooted" at the associated entity.

Functionally equivalent to Criteria.createCriteria(String,int) using Criteria.INNER_JOIN for the joinType.
Parameters:
  associationPath - A dot-seperated property path the created "sub criteria"




createCriteria
public Criteria createCriteria(String associationPath, int joinType) throws HibernateException(Code)
Create a new Criteria, "rooted" at the associated entity, using the specified join type.
Parameters:
  associationPath - A dot-seperated property path
Parameters:
  joinType - The type of join to use. the created "sub criteria"



createCriteria
public Criteria createCriteria(String associationPath, String alias) throws HibernateException(Code)
Create a new Criteria, "rooted" at the associated entity, assigning the given alias.

Functionally equivalent to Criteria.createCriteria(String,String,int) using Criteria.INNER_JOIN for the joinType.
Parameters:
  associationPath - A dot-seperated property path
Parameters:
  alias - The alias to assign to the joined association (for later reference). the created "sub criteria"




createCriteria
public Criteria createCriteria(String associationPath, String alias, int joinType) throws HibernateException(Code)
Create a new Criteria, "rooted" at the associated entity, assigning the given alias and using the specified join type.
Parameters:
  associationPath - A dot-seperated property path
Parameters:
  alias - The alias to assign to the joined association (for later reference).
Parameters:
  joinType - The type of join to use. the created "sub criteria"



getAlias
public String getAlias()(Code)
Get the alias of the entity encapsulated by this criteria instance. The alias for the encapsulated entity.



list
public List list() throws HibernateException(Code)
Get the results. The list of matched query results.



scroll
public ScrollableResults scroll() throws HibernateException(Code)
Get the results as an instance of ScrollableResults The ScrollableResults representing the matchedquery results.



scroll
public ScrollableResults scroll(ScrollMode scrollMode) throws HibernateException(Code)
Get the results as an instance of ScrollableResults based on the given scroll mode.
Parameters:
  scrollMode - Indicates the type of underlying database cursor torequest. The ScrollableResults representing the matchedquery results.



setCacheMode
public Criteria setCacheMode(CacheMode cacheMode)(Code)
Override the cache mode for this particular query.
Parameters:
  cacheMode - The cache mode to use. this (for method chaining)



setCacheRegion
public Criteria setCacheRegion(String cacheRegion)(Code)
Set the name of the cache region to use for query result caching.
Parameters:
  cacheRegion - the name of a query cache region, or nullfor the default query cache this (for method chaining)
See Also:   Criteria.setCacheable



setCacheable
public Criteria setCacheable(boolean cacheable)(Code)
Enable caching of this query result, provided query caching is enabled for the underlying session factory.
Parameters:
  cacheable - Should the result be considered cacheable; default isto not cache (false). this (for method chaining)



setComment
public Criteria setComment(String comment)(Code)
Add a comment to the generated SQL.
Parameters:
  comment - a human-readable string this (for method chaining)



setFetchMode
public Criteria setFetchMode(String associationPath, FetchMode mode) throws HibernateException(Code)
Specify an association fetching strategy for an association or a collection of values.
Parameters:
  associationPath - a dot seperated property path
Parameters:
  mode - The fetch mode for the referenced association this (for method chaining)



setFetchSize
public Criteria setFetchSize(int fetchSize)(Code)
Set a fetch size for the underlying JDBC query.
Parameters:
  fetchSize - the fetch size this (for method chaining)
See Also:   java.sql.Statement.setFetchSize



setFirstResult
public Criteria setFirstResult(int firstResult)(Code)
Set the first result to be retrieved.
Parameters:
  firstResult - the first result to retrieve, numbered from 0 this (for method chaining)



setFlushMode
public Criteria setFlushMode(FlushMode flushMode)(Code)
Override the flush mode for this particular query.
Parameters:
  flushMode - The flush mode to use. this (for method chaining)



setLockMode
public Criteria setLockMode(LockMode lockMode)(Code)
Set the lock mode of the current entity
Parameters:
  lockMode - The lock mode to be applied this (for method chaining)



setLockMode
public Criteria setLockMode(String alias, LockMode lockMode)(Code)
Set the lock mode of the aliased entity
Parameters:
  alias - The previously assigned alias representing the entity towhich the given lock mode should apply.
Parameters:
  lockMode - The lock mode to be applied this (for method chaining)



setMaxResults
public Criteria setMaxResults(int maxResults)(Code)
Set a limit upon the number of objects to be retrieved.
Parameters:
  maxResults - the maximum number of results this (for method chaining)



setProjection
public Criteria setProjection(Projection projection)(Code)
Used to specify that the query results will be a projection (scalar in nature). Implicitly specifies the Criteria.PROJECTION result transformer.

The individual components contained within the given Projection projection determines the overall "shape" of the query result.
Parameters:
  projection - The projection representing the overall "shape" of thequery results. this (for method chaining)




setResultTransformer
public Criteria setResultTransformer(ResultTransformer resultTransformer)(Code)
Set a strategy for handling the query results. This determines the "shape" of the query result.
Parameters:
  resultTransformer - The transformer to apply this (for method chaining)
See Also:   Criteria.ROOT_ENTITY
See Also:   Criteria.DISTINCT_ROOT_ENTITY
See Also:   Criteria.ALIAS_TO_ENTITY_MAP
See Also:   Criteria.PROJECTION



setTimeout
public Criteria setTimeout(int timeout)(Code)
Set a timeout for the underlying JDBC query.
Parameters:
  timeout - The timeout value to apply. this (for method chaining)
See Also:   java.sql.Statement.setQueryTimeout



uniqueResult
public Object uniqueResult() throws HibernateException(Code)
Convenience method to return a single instance that matches the query, or null if the query returns no results. the single result or null
throws:
  HibernateException - if there is more than one matching result



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.