net.sf.basedb.core
Class AnnotationInRestriction
java.lang.Object
net.sf.basedb.core.AnnotationRestriction
net.sf.basedb.core.AnnotationInRestriction
- All Implemented Interfaces:
- QueryElement, Restriction
public class AnnotationInRestriction
- extends AnnotationRestriction
Restricts a query using annotation values that exists in a set
of given values.
- Version:
- 2.0
- Author:
- Nicklas
- See Also:
Annotations
- Last modified
- $Date: 2008-09-11 22:11:02 +0200 (Thu, 11 Sep 2008) $
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
values
private final List<?> values
AnnotationInRestriction
public AnnotationInRestriction(AnnotationType annotationType,
boolean includeInheriting,
Object... values)
throws InvalidDataException
- Deprecated. Use
AnnotationInRestriction(String, AnnotationType, boolean, Object[])
instead with alias=null
- Create a new annotation restriction.
- Throws:
InvalidDataException
AnnotationInRestriction
public AnnotationInRestriction(String alias,
AnnotationType annotationType,
boolean includeInheriting,
Object... values)
throws InvalidDataException
- Create a new annotation restriction.
- Parameters:
alias
- The alias to use in the restriction.annotationType
- The annotation type to use in the queryincludeInheriting
- If items inherting the annotation should be returned
by the query or notvalues
- An array of values, each value must be of the
correct value type for the annotation as defined by the
AnnotationType.getValueType()
property
- Throws:
InvalidDataException
- If any of the parameters are null
or the array is empty or not follow the rules above.- Since:
- 2.4
getRestrictionSql
String getRestrictionSql(Query query,
DbControl dc)
throws BaseException
- Description copied from class:
AnnotationRestriction
- Get an SQL fragment that includes the actual restriction.
Use 'v.value' to access the annotation value. Avoid including
literal values originating from a user, especially strings, since it may lead
to security holes unless the values are checked
for dangerous characters. Use a parameter placeholder instead. A parameter
placeholder is a colon (:) followed by a name.
Example:
v.value = :theValue
The setRestrictionParameters
method is called to
allow the subclass to set the value of the parameters specified
in the SQL fragment.
- Specified by:
getRestrictionSql
in class AnnotationRestriction
- Parameters:
query
- The query object we are about to execute
- Returns:
- An SQL fragment, or null if no additional restriction is required
- Throws:
BaseException
- See Also:
AnnotationRestriction.setRestrictionParameters(SQLQuery)
setRestrictionParameters
void setRestrictionParameters(SQLQuery query)
- Description copied from class:
AnnotationRestriction
- Set the value for all parameters defined in the SQL fragment
returned by
AnnotationRestriction.getRestrictionSql(Query, DbControl)
.
- Specified by:
setRestrictionParameters
in class AnnotationRestriction
- Parameters:
query
- The Hibernate SQLQuery
object which is
used to query the database