Interface IIvyQuery
-
public interface IIvyQuery
Interface used to control query execution for the persistence API.- Since:
- 08.05.2009
- API:
- This is a public API.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description 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.IIvyQuery
setFirstResult(int startPosition)
Set the position of the first result to retrieve.IIvyQuery
setFlushMode(javax.persistence.FlushModeType flushMode)
Set the flush mode type to be used for the query execution.IIvyQuery
setHint(String hintName, Object value)
Set an implementation-specific hint.IIvyQuery
setMaxResults(int maxResult)
Set the maximum number of results to retrieve.IIvyQuery
setParameter(int position, Object value)
Bind an argument to a positional parameter.IIvyQuery
setParameter(int position, Calendar value, javax.persistence.TemporalType temporalType)
Bind an instance of java.util.Calendar to a positional parameter.IIvyQuery
setParameter(int position, Date value, javax.persistence.TemporalType temporalType)
Bind an instance of java.util.Date to a positional parameter.IIvyQuery
setParameter(String name, Object value)
Bind an argument to a named parameter.IIvyQuery
setParameter(String name, Calendar value, javax.persistence.TemporalType temporalType)
Bind an instance of java.util.Calendar to a named parameter.IIvyQuery
setParameter(String name, Date value, javax.persistence.TemporalType temporalType)
Bind an instance of java.util.Date to a named parameter.
-
-
-
Method Detail
-
getResultList
List<?> getResultList()
Execute a SELECT query and return the query results as a List. Per default (no user transaction open) the operation closes the transaction, means neithergetResultList()
norgetSingleResult()
.- Returns:
- a list of the results
- Throws:
IllegalStateException
- if called for a Java Persistence query language UPDATE or DELETE statement or if underlying entity manager is already closed then you can not execute this query again- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
getSingleResult
Object getSingleResult()
Execute a SELECT query that returns a single result. Per default (no user transaction open) the operation closes the transaction, means neithergetResultList()
norgetSingleResult()
.- Returns:
- the result
- Throws:
javax.persistence.NoResultException
- if there is no resultjavax.persistence.NonUniqueResultException
- if more than one resultIllegalStateException
- if called for a Java Persistence query language UPDATE or DELETE statement or if underlying entity manager is already closed then you can not execute this query again- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
executeUpdate
int executeUpdate()
Execute an update or delete statement. Per default (no user transaction open) the operation closes the transaction, meansexecuteUpdate()
can not be called again.- Returns:
- the number of entities updated or deleted
- Throws:
IllegalStateException
- if called for a Java Persistence query language SELECT statement or if underlying entity manager is already closed then you can not execute this query againjavax.persistence.TransactionRequiredException
- if there is no transaction- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
setMaxResults
IIvyQuery setMaxResults(int maxResult)
Set the maximum number of results to retrieve.- Parameters:
maxResult
-- Returns:
- the same query instance
- Throws:
IllegalArgumentException
- if argument is negative- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
setFirstResult
IIvyQuery 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- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
setHint
IIvyQuery 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- API:
- This public API is available in IvyScript and Java. It has the visibility EXPERT.
-
setParameter
IIvyQuery 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- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
setParameter
IIvyQuery setParameter(String name, Date value, javax.persistence.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 a parameter of the query- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
setParameter
IIvyQuery setParameter(String name, Calendar value, javax.persistence.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 a parameter of the query- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
setParameter
IIvyQuery 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- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
setParameter
IIvyQuery setParameter(int position, Date value, javax.persistence.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 a positional parameter of the query- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
setParameter
IIvyQuery setParameter(int position, Calendar value, javax.persistence.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 a positional parameter of the query- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
setFlushMode
IIvyQuery setFlushMode(javax.persistence.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
-- Returns:
- the same query instance
- API:
- This public API is available in IvyScript and Java. It has the visibility EXPERT.
-
-