Class NamedParameters
- java.lang.Object
-
- org.silverpeas.core.persistence.datasource.repository.jpa.NamedParameters
-
- All Implemented Interfaces:
Parameters
- Direct Known Subclasses:
NoNamedParameter
public class NamedParameters extends Object implements Parameters
This class permits to handle as a friendly way the named parameters of a query.Use
add(java.lang.String, java.lang.Object)
method to add a named parameter (its name, its value and optionally a temporal type).Use
applyTo(E)
to apply the named parameter to the query. This method returns the query passed, so that query methods can be called directly in one line of code.- Author:
- Yohann Chastagnier
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NamedParameters
add(String name, Object value)
Adding a new named parameter.NamedParameters
add(String name, Object value, javax.persistence.TemporalType temporalType)
Adding a new temporal named parameter.<E extends javax.persistence.Query>
EapplyTo(E query)
Applies the named parameters to the given query.String
getLastParameterName()
Gets the last parameter.<T> NamedParameter<T>
getParameter(String parameterName)
Gets the specified parameter.
-
-
-
Method Detail
-
getLastParameterName
public String getLastParameterName()
Gets the last parameter.- Returns:
- the name of the last added parameter.
-
getParameter
public <T> NamedParameter<T> getParameter(String parameterName)
Gets the specified parameter.- Parameters:
parameterName
- the name of the parameter.- Returns:
- the parameter or null if no such parameter exists.
-
add
public NamedParameters add(String name, Object value)
Adding a new named parameter.- Specified by:
add
in interfaceParameters
- Parameters:
name
- the parameter name.value
- the parameter value.- Returns:
- itself.
-
add
public NamedParameters add(String name, Object value, javax.persistence.TemporalType temporalType)
Adding a new temporal named parameter.- Parameters:
name
- the parameter name.value
- the parameter value.temporalType
- the temporal type of the parameter.- Returns:
- itself.
-
applyTo
public <E extends javax.persistence.Query> E applyTo(E query)
Applies the named parameters to the given query.- Type Parameters:
E
- the type of the JPQL query.- Parameters:
query
- the query on which the parameters have to be applied.- Returns:
- the JPQL query enriched with the parameters.
-
-