Java Doc for Query.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.Query

All known Subclasses:   org.hibernate.impl.AbstractQueryImpl,
Query
public interface Query (Code)
An object-oriented representation of a Hibernate query. A Query instance is obtained by calling Session.createQuery(). This interface exposes some extra functionality beyond that provided by Session.iterate() and Session.find():
  • a particular page of the result set may be selected by calling setMaxResults(), setFirstResult()
  • named query parameters may be used
  • the results may be returned as an instance of ScrollableResults

Named query parameters are tokens of the form :name in the query string. A value is bound to the integer parameter :foo by calling

setParameter("foo", foo, Hibernate.INTEGER);

for example. A name may appear multiple times in the query string.

JDBC-style ? parameters are also supported. To bind a value to a JDBC-style parameter use a set method that accepts an int positional argument (numbered from zero, contrary to JDBC).

You may not mix and match JDBC-style parameters and named parameters in the same query.

Queries are executed by calling list(), scroll() or iterate(). A query may be re-executed by subsequent invocations. Its lifespan is, however, bounded by the lifespan of the Session that created it.

Implementors are not intended to be threadsafe.
See Also:   org.hibernate.Session.createQuery(java.lang.String)
See Also:   org.hibernate.ScrollableResults
author:
   Gavin King




Method Summary
public  intexecuteUpdate()
     Execute the update or delete statement.
public  String[]getNamedParameters()
     Return the names of all named parameters of the query.
public  StringgetQueryString()
     Get the query string.
public  String[]getReturnAliases()
    
public  Type[]getReturnTypes()
     Return the Hibernate types of the query result set.
public  Iteratoriterate()
     Return the query results as an Iterator.
public  Listlist()
     Return the query results as a List.
public  ScrollableResultsscroll()
     Return the query results as ScrollableResults.
public  ScrollableResultsscroll(ScrollMode scrollMode)
     Return the query results as ScrollableResults.
public  QuerysetBigDecimal(int position, BigDecimal number)
    
public  QuerysetBigDecimal(String name, BigDecimal number)
    
public  QuerysetBigInteger(int position, BigInteger number)
    
public  QuerysetBigInteger(String name, BigInteger number)
    
public  QuerysetBinary(int position, byte[] val)
    
public  QuerysetBinary(String name, byte[] val)
    
public  QuerysetBoolean(int position, boolean val)
    
public  QuerysetBoolean(String name, boolean val)
    
public  QuerysetByte(int position, byte val)
    
public  QuerysetByte(String name, byte val)
    
public  QuerysetCacheMode(CacheMode cacheMode)
     Override the current session cache mode, just for this query.
public  QuerysetCacheRegion(String cacheRegion)
     Set the name of the cache region.
public  QuerysetCacheable(boolean cacheable)
     Enable caching of this query result set.
public  QuerysetCalendar(int position, Calendar calendar)
    
public  QuerysetCalendar(String name, Calendar calendar)
    
public  QuerysetCalendarDate(int position, Calendar calendar)
    
public  QuerysetCalendarDate(String name, Calendar calendar)
    
public  QuerysetCharacter(int position, char val)
    
public  QuerysetCharacter(String name, char val)
    
public  QuerysetComment(String comment)
     Add a comment to the generated SQL.
public  QuerysetDate(int position, Date date)
    
public  QuerysetDate(String name, Date date)
    
public  QuerysetDouble(int position, double val)
    
public  QuerysetDouble(String name, double val)
    
public  QuerysetEntity(int position, Object val)
     Bind an instance of a mapped persistent class to a JDBC-style query parameter.
public  QuerysetEntity(String name, Object val)
     Bind an instance of a mapped persistent class to a named query parameter.
public  QuerysetFetchSize(int fetchSize)
     Set a fetch size for the underlying JDBC query.
public  QuerysetFirstResult(int firstResult)
     Set the first row to retrieve.
public  QuerysetFloat(int position, float val)
    
public  QuerysetFloat(String name, float val)
    
public  QuerysetFlushMode(FlushMode flushMode)
     Override the current session flush mode, just for this query.
public  QuerysetInteger(int position, int val)
    
public  QuerysetInteger(String name, int val)
    
public  QuerysetLocale(int position, Locale locale)
    
public  QuerysetLocale(String name, Locale locale)
    
public  QuerysetLockMode(String alias, LockMode lockMode)
     Set the lockmode for the objects idententified by the given alias that appears in the FROM clause.
public  QuerysetLong(int position, long val)
    
public  QuerysetLong(String name, long val)
    
public  QuerysetMaxResults(int maxResults)
     Set the maximum number of rows to retrieve.
public  QuerysetParameter(int position, Object val, Type type)
     Bind a value to a JDBC-style query parameter.
public  QuerysetParameter(String name, Object val, Type type)
     Bind a value to a named query parameter.
public  QuerysetParameter(int position, Object val)
     Bind a value to a JDBC-style query parameter.
public  QuerysetParameter(String name, Object val)
     Bind a value to a named query parameter.
public  QuerysetParameterList(String name, Collection vals, Type type)
     Bind multiple values to a named query parameter.
public  QuerysetParameterList(String name, Collection vals)
     Bind multiple values to a named query parameter.
public  QuerysetParameterList(String name, Object[] vals, Type type)
     Bind multiple values to a named query parameter.
public  QuerysetParameterList(String name, Object[] vals)
     Bind multiple values to a named query parameter.
public  QuerysetParameters(Object[] values, Type[] types)
     Bind values and types to positional parameters.
public  QuerysetProperties(Object bean)
     Bind the property values of the given bean to named parameters of the query, matching property names with parameter names and mapping property types to Hibernate types using hueristics.
public  QuerysetProperties(Map bean)
     Bind the values of the given Map for each named parameters of the query, matching key names with parameter names and mapping value types to Hibernate types using hueristics.
public  QuerysetReadOnly(boolean readOnly)
     Entities retrieved by this query will be loaded in a read-only mode where Hibernate will never dirty-check them or make changes persistent.
public  QuerysetResultTransformer(ResultTransformer transformer)
     Set a strategy for handling the query results.
public  QuerysetSerializable(int position, Serializable val)
    
public  QuerysetSerializable(String name, Serializable val)
    
public  QuerysetShort(int position, short val)
    
public  QuerysetShort(String name, short val)
    
public  QuerysetString(int position, String val)
    
public  QuerysetString(String name, String val)
    
public  QuerysetText(int position, String val)
    
public  QuerysetText(String name, String val)
    
public  QuerysetTime(int position, Date date)
    
public  QuerysetTime(String name, Date date)
    
public  QuerysetTimeout(int timeout)
     Set a timeout for the underlying JDBC query.
public  QuerysetTimestamp(int position, Date date)
    
public  QuerysetTimestamp(String name, Date date)
    
public  ObjectuniqueResult()
     Convenience method to return a single instance that matches the query, or null if the query returns no results.



Method Detail
executeUpdate
public int executeUpdate() throws HibernateException(Code)
Execute the update or delete statement.

The semantics are compliant with the ejb3 Query.executeUpdate() method. The number of entities updated or deleted.
throws:
  HibernateException -



getNamedParameters
public String[] getNamedParameters() throws HibernateException(Code)
Return the names of all named parameters of the query. the parameter names, in no particular order



getQueryString
public String getQueryString()(Code)
Get the query string. the query string



getReturnAliases
public String[] getReturnAliases() throws HibernateException(Code)
Return the HQL select clause aliases (if any) an array of aliases as strings



getReturnTypes
public Type[] getReturnTypes() throws HibernateException(Code)
Return the Hibernate types of the query result set. an array of types



iterate
public Iterator iterate() throws HibernateException(Code)
Return the query results as an Iterator. If the query contains multiple results pre row, the results are returned in an instance of Object[].

Entities returned as results are initialized on demand. The first SQL query returns identifiers only.
the result iterator
throws:
  HibernateException -



list
public List list() throws HibernateException(Code)
Return the query results as a List. If the query contains multiple results pre row, the results are returned in an instance of Object[]. the result list
throws:
  HibernateException -



scroll
public ScrollableResults scroll() throws HibernateException(Code)
Return the query results as ScrollableResults. The scrollability of the returned results depends upon JDBC driver support for scrollable ResultSets.

See Also:   ScrollableResults the result iterator
throws:
  HibernateException -



scroll
public ScrollableResults scroll(ScrollMode scrollMode) throws HibernateException(Code)
Return the query results as ScrollableResults. The scrollability of the returned results depends upon JDBC driver support for scrollable ResultSets.

See Also:   ScrollableResults
See Also:   ScrollMode the result iterator
throws:
  HibernateException -



setBigDecimal
public Query setBigDecimal(int position, BigDecimal number)(Code)



setBigDecimal
public Query setBigDecimal(String name, BigDecimal number)(Code)



setBigInteger
public Query setBigInteger(int position, BigInteger number)(Code)



setBigInteger
public Query setBigInteger(String name, BigInteger number)(Code)



setBinary
public Query setBinary(int position, byte[] val)(Code)



setBinary
public Query setBinary(String name, byte[] val)(Code)



setBoolean
public Query setBoolean(int position, boolean val)(Code)



setBoolean
public Query setBoolean(String name, boolean val)(Code)



setByte
public Query setByte(int position, byte val)(Code)



setByte
public Query setByte(String name, byte val)(Code)



setCacheMode
public Query setCacheMode(CacheMode cacheMode)(Code)
Override the current session cache mode, just for this query.
See Also:   org.hibernate.CacheMode



setCacheRegion
public Query setCacheRegion(String cacheRegion)(Code)
Set the name of the cache region.
Parameters:
  cacheRegion - the name of a query cache region, or nullfor the default query cache



setCacheable
public Query setCacheable(boolean cacheable)(Code)
Enable caching of this query result set.
Parameters:
  cacheable - Should the query results be cacheable?



setCalendar
public Query setCalendar(int position, Calendar calendar)(Code)



setCalendar
public Query setCalendar(String name, Calendar calendar)(Code)



setCalendarDate
public Query setCalendarDate(int position, Calendar calendar)(Code)



setCalendarDate
public Query setCalendarDate(String name, Calendar calendar)(Code)



setCharacter
public Query setCharacter(int position, char val)(Code)



setCharacter
public Query setCharacter(String name, char val)(Code)



setComment
public Query setComment(String comment)(Code)
Add a comment to the generated SQL.
Parameters:
  comment - a human-readable string



setDate
public Query setDate(int position, Date date)(Code)



setDate
public Query setDate(String name, Date date)(Code)



setDouble
public Query setDouble(int position, double val)(Code)



setDouble
public Query setDouble(String name, double val)(Code)



setEntity
public Query setEntity(int position, Object val)(Code)
Bind an instance of a mapped persistent class to a JDBC-style query parameter.
Parameters:
  position - the position of the parameter in the querystring, numbered from 0.
Parameters:
  val - a non-null instance of a persistent class



setEntity
public Query setEntity(String name, Object val)(Code)
Bind an instance of a mapped persistent class to a named query parameter.
Parameters:
  name - the name of the parameter
Parameters:
  val - a non-null instance of a persistent class



setFetchSize
public Query setFetchSize(int fetchSize)(Code)
Set a fetch size for the underlying JDBC query.
Parameters:
  fetchSize - the fetch size



setFirstResult
public Query setFirstResult(int firstResult)(Code)
Set the first row to retrieve. If not set, rows will be retrieved beginnning from row 0.
Parameters:
  firstResult - a row number, numbered from 0



setFloat
public Query setFloat(int position, float val)(Code)



setFloat
public Query setFloat(String name, float val)(Code)



setFlushMode
public Query setFlushMode(FlushMode flushMode)(Code)
Override the current session flush mode, just for this query.
See Also:   org.hibernate.FlushMode



setInteger
public Query setInteger(int position, int val)(Code)



setInteger
public Query setInteger(String name, int val)(Code)



setLocale
public Query setLocale(int position, Locale locale)(Code)



setLocale
public Query setLocale(String name, Locale locale)(Code)



setLockMode
public Query setLockMode(String alias, LockMode lockMode)(Code)
Set the lockmode for the objects idententified by the given alias that appears in the FROM clause.
Parameters:
  alias - a query alias, or this for a collection filter



setLong
public Query setLong(int position, long val)(Code)



setLong
public Query setLong(String name, long val)(Code)



setMaxResults
public Query setMaxResults(int maxResults)(Code)
Set the maximum number of rows to retrieve. If not set, there is no limit to the number of rows retrieved.
Parameters:
  maxResults - the maximum number of rows



setParameter
public Query setParameter(int position, Object val, Type type)(Code)
Bind a value to a JDBC-style query parameter.
Parameters:
  position - the position of the parameter in the querystring, numbered from 0.
Parameters:
  val - the possibly-null parameter value
Parameters:
  type - the Hibernate type



setParameter
public Query setParameter(String name, Object val, Type type)(Code)
Bind a value to a named query parameter.
Parameters:
  name - the name of the parameter
Parameters:
  val - the possibly-null parameter value
Parameters:
  type - the Hibernate type



setParameter
public Query setParameter(int position, Object val) throws HibernateException(Code)
Bind a value to a JDBC-style query parameter. The Hibernate type of the parameter is first detected via the usage/position in the query and if not sufficient secondly guessed from the class of the given object.
Parameters:
  position - the position of the parameter in the querystring, numbered from 0.
Parameters:
  val - the non-null parameter value
throws:
  org.hibernate.HibernateException - if no type could be determined



setParameter
public Query setParameter(String name, Object val) throws HibernateException(Code)
Bind a value to a named query parameter. The Hibernate type of the parameter is first detected via the usage/position in the query and if not sufficient secondly guessed from the class of the given object.
Parameters:
  name - the name of the parameter
Parameters:
  val - the non-null parameter value
throws:
  org.hibernate.HibernateException - if no type could be determined



setParameterList
public Query setParameterList(String name, Collection vals, Type type) throws HibernateException(Code)
Bind multiple values to a named query parameter. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).
Parameters:
  name - the name of the parameter
Parameters:
  vals - a collection of values to list
Parameters:
  type - the Hibernate type of the values



setParameterList
public Query setParameterList(String name, Collection vals) throws HibernateException(Code)
Bind multiple values to a named query parameter. The Hibernate type of the parameter is first detected via the usage/position in the query and if not sufficient secondly guessed from the class of the first object in the collection. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).
Parameters:
  name - the name of the parameter
Parameters:
  vals - a collection of values to list



setParameterList
public Query setParameterList(String name, Object[] vals, Type type) throws HibernateException(Code)
Bind multiple values to a named query parameter. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).
Parameters:
  name - the name of the parameter
Parameters:
  vals - a collection of values to list
Parameters:
  type - the Hibernate type of the values



setParameterList
public Query setParameterList(String name, Object[] vals) throws HibernateException(Code)
Bind multiple values to a named query parameter. The Hibernate type of the parameter is first detected via the usage/position in the query and if not sufficient secondly guessed from the class of the first object in the array. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).
Parameters:
  name - the name of the parameter
Parameters:
  vals - a collection of values to list



setParameters
public Query setParameters(Object[] values, Type[] types) throws HibernateException(Code)
Bind values and types to positional parameters.



setProperties
public Query setProperties(Object bean) throws HibernateException(Code)
Bind the property values of the given bean to named parameters of the query, matching property names with parameter names and mapping property types to Hibernate types using hueristics.
Parameters:
  bean - any JavaBean or POJO



setProperties
public Query setProperties(Map bean) throws HibernateException(Code)
Bind the values of the given Map for each named parameters of the query, matching key names with parameter names and mapping value types to Hibernate types using hueristics.
Parameters:
  bean - a java.util.Map



setReadOnly
public Query setReadOnly(boolean readOnly)(Code)
Entities retrieved by this query will be loaded in a read-only mode where Hibernate will never dirty-check them or make changes persistent.



setResultTransformer
public Query setResultTransformer(ResultTransformer transformer)(Code)
Set a strategy for handling the query results. This can be used to change "shape" of the query result.
Parameters:
  transformer - The transformer to apply this (for method chaining)



setSerializable
public Query setSerializable(int position, Serializable val)(Code)



setSerializable
public Query setSerializable(String name, Serializable val)(Code)



setShort
public Query setShort(int position, short val)(Code)



setShort
public Query setShort(String name, short val)(Code)



setString
public Query setString(int position, String val)(Code)



setString
public Query setString(String name, String val)(Code)



setText
public Query setText(int position, String val)(Code)



setText
public Query setText(String name, String val)(Code)



setTime
public Query setTime(int position, Date date)(Code)



setTime
public Query setTime(String name, Date date)(Code)



setTimeout
public Query setTimeout(int timeout)(Code)
Set a timeout for the underlying JDBC query.
Parameters:
  timeout - the timeout in seconds



setTimestamp
public Query setTimestamp(int position, Date date)(Code)



setTimestamp
public Query setTimestamp(String name, Date date)(Code)



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:
  NonUniqueResultException - 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.