|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
javax.persistence Interface Query
public interface Query
用于控制查询执行的接口。
since |
|
Interface used to control query execution.
- Since:
- Java Persistence 1.0
Method Summary | |
---|---|
int |
executeUpdate()
Execute an update or delete statement. |
List |
getResultList()
Execute a SELECT query and return the query results as a List. |
Object |
getSingleResult()
Execute a SELECT query that returns a single result. |
Query |
setFirstResult(int startPosition)
Set the position of the first result to retrieve. |
Query |
setFlushMode(FlushModeType flushMode)
Set the flush mode type to be used for the query execution. |
Query |
setHint(String hintName,
Object value)
Set an implementation-specific hint. |
Query |
setMaxResults(int maxResult)
Set the maximum number of results to retrieve. |
Query |
setParameter(int position,
Calendar value,
TemporalType temporalType)
Bind an instance of java.util.Calendar to a positional parameter. |
Query |
setParameter(int position,
Date value,
TemporalType temporalType)
Bind an instance of java.util.Date to a positional parameter. |
Query |
setParameter(int position,
Object value)
Bind an argument to a positional parameter. |
Query |
setParameter(String name,
Calendar value,
TemporalType temporalType)
Bind an instance of java.util.Calendar to a named parameter. |
Query |
setParameter(String name,
Date value,
TemporalType temporalType)
Bind an instance of java.util.Date to a named parameter. |
Query |
setParameter(String name,
Object value)
Bind an argument to a named parameter. |
Method Detail |
---|
public java.util.List<E>
getResultList()
执行 SELECT 查询并将查询结果作为 List 返回。
return | 结果列表 |
Throws | IllegalStateException: 如果对 Java Persistence 查询语言 UPDATE 或 DELETE 语句调用 |
getResultList
List getResultList()
- Execute a SELECT query and return the query results
as a List.
- Returns:
- a list of the results
- Throws:
IllegalStateException
- if called for a Java Persistence query language UPDATE or DELETE statement
public Object
getSingleResult()
执行返回单个结果的 SELECT 查询。
return | 结果 |
Throws | NoResultException: 如果不存在结果 |
Throws | NonUniqueResultException: 如果有多个结果 |
Throws | IllegalStateException: 如果对 Java Persistence 查询语言 UPDATE 或 DELETE 语句调用 |
getSingleResult
Object getSingleResult()
- Execute a SELECT query that returns a single result.
- Returns:
- the result
- Throws:
NoResultException
- if there is no resultNonUniqueResultException
- if more than one resultIllegalStateException
- if called for a Java Persistence query language UPDATE or DELETE statement
public int
executeUpdate()
执行更新或删除语句。
return | 更新或删除的实体数目 |
Throws | IllegalStateException: 如果对 Java Persistence 查询语言 SELECT 语句调用 |
Throws | TransactionRequiredException: 如果没有事务 |
executeUpdate
int executeUpdate()
- Execute an update or delete statement.
- Returns:
- the number of entities updated or deleted
- Throws:
IllegalStateException
- if called for a Java Persistence query language SELECT statementTransactionRequiredException
- if there is no transaction
public Query
setMaxResults(int maxResult)
设置要获取的结果的最大数目。
maxResult | |
return | 相同的查询实例 |
Throws | IllegalArgumentException: 如果参数为负 |
setMaxResults
Query setMaxResults(int maxResult)
- Set the maximum number of results to retrieve.
- Parameters:
maxResult
-- Returns:
- the same query instance
- Throws:
IllegalArgumentException
- if argument is negative
public Query
setFirstResult(int startPosition)
设置要获取的第一个结果的位置。
startPosition | 第一个结果的起始位置,从 0 开始编号 |
return | 相同的查询实例 |
Throws | IllegalArgumentException: 如果参数为负 |
setFirstResult
Query setFirstResult(int startPosition)
- Set the position of the first result to retrieve.
- Parameters:
startPosition
- the start position of the first result, numbered from 0- Returns:
- the same query instance
- Throws:
IllegalArgumentException
- if argument is negative
public Query
setHint(String hintName, Object value)
设置特定于实现的提示。如果提示名称无法识别,则忽略即可。
hintName | |
value | |
return | 相同的查询实例 |
Throws | IllegalArgumentException: 如果第二个参数对实现无效 |
setHint
Query setHint(String hintName, Object value)
- Set an implementation-specific hint.
If the hint name is not recognized, it is silently ignored.
- Parameters:
hintName
-value
-- Returns:
- the same query instance
- Throws:
IllegalArgumentException
- if the second argument is not valid for the implementation
public Query
setParameter(String name, Object value)
将实参绑定到指定形参。
name | 参数名 |
value | |
return | 相同的查询实例 |
Throws | IllegalArgumentException: 如果形参名称与查询字符串中的形参不对应,或者实参的类型错误 |
setParameter
Query setParameter(String name, Object value)
- Bind an argument to a named parameter.
- Parameters:
name
- the parameter namevalue
-- Returns:
- the same query instance
- Throws:
IllegalArgumentException
- if parameter name does not correspond to parameter in query string or argument is of incorrect type
public Query
setParameter(String name, java.util.Date value, TemporalType temporalType)
将 java.util.Date 实例绑定到指定的参数。
name | |
value | |
temporalType | |
return | 相同的查询实例 |
Throws | IllegalArgumentException: 如果参数名称与查询字符串中的参数不对应 |
setParameter
Query setParameter(String name, Date value, TemporalType temporalType)
- Bind an instance of java.util.Date to a named parameter.
- Parameters:
name
-value
-temporalType
-- Returns:
- the same query instance
- Throws:
IllegalArgumentException
- if parameter name does not correspond to parameter in query string
public Query
setParameter(String name, java.util.Calendar value, TemporalType temporalType)
将 java.util.Calendar 实例绑定到指定的参数。
name | |
value | |
temporalType | |
return | 相同的查询实例 |
Throws | IllegalArgumentException: 如果参数名称与查询字符串中的参数不对应 |
setParameter
Query setParameter(String name, Calendar value, TemporalType temporalType)
- Bind an instance of java.util.Calendar to a named parameter.
- Parameters:
name
-value
-temporalType
-- Returns:
- the same query instance
- Throws:
IllegalArgumentException
- if parameter name does not correspond to parameter in query string
public Query
setParameter(int position, Object value)
将实参绑定到位置形参。
position | |
value | |
return | 相同的查询实例 |
Throws | IllegalArgumentException: 如果位置与查询的位置实参不对应,或者实参的类型错误 |
setParameter
Query setParameter(int position, Object value)
- Bind an argument to a positional parameter.
- Parameters:
position
-value
-- Returns:
- the same query instance
- Throws:
IllegalArgumentException
- if position does not correspond to positional parameter of query or argument is of incorrect type
public Query
setParameter(int position, java.util.Date value, TemporalType temporalType)
将 java.util.Date 实例绑定到位置参数。
position | |
value | |
temporalType | |
return | 相同的查询实例 |
Throws | IllegalArgumentException: 如果位置与查询的位置参数不对应 |
setParameter
Query setParameter(int position, Date value, TemporalType temporalType)
- Bind an instance of java.util.Date to a positional parameter.
- Parameters:
position
-value
-temporalType
-- Returns:
- the same query instance
- Throws:
IllegalArgumentException
- if position does not correspond to positional parameter of query
public Query
setParameter(int position, java.util.Calendar value, TemporalType temporalType)
将 java.util.Calendar 实例绑定到位置参数。
position | |
value | |
temporalType | |
return | 相同的查询实例 |
Throws | IllegalArgumentException: 如果位置与查询的位置参数不对应 |
setParameter
Query setParameter(int position, Calendar value, TemporalType temporalType)
- Bind an instance of java.util.Calendar to a positional parameter.
- Parameters:
position
-value
-temporalType
-- Returns:
- the same query instance
- Throws:
IllegalArgumentException
- if position does not correspond to positional parameter of query
public Query
setFlushMode(FlushModeType flushMode)
设置执行查询要使用的刷新模式类型。不管实例管理器使用的刷新模式类型如何,此刷新模式类型都将应用于查询。
flushMode |
setFlushMode
Query setFlushMode(FlushModeType flushMode)
- Set the flush mode type to be used for the query execution.
The flush mode type applies to the query regardless of the
flush mode type in use for the entity manager.
- Parameters:
flushMode
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!