Package net.sf.basedb.core
Class AnnotationSimpleRestriction
java.lang.Object
net.sf.basedb.core.AnnotationRestriction
net.sf.basedb.core.AnnotationSimpleRestriction
- All Implemented Interfaces:
QueryElement
,Restriction
Restricts a query using annotation values with a simple expression:
annotation operator value
.- Version:
- 2.0
- Author:
- Nicklas
- See Also:
- Last modified
- $Date: 2019-03-12 08:29:06 +0100 (tis, 12 mars 2019) $
-
Nested Class Summary
Nested classes/interfaces inherited from class net.sf.basedb.core.AnnotationRestriction
AnnotationRestriction.Options
-
Field Summary
Modifier and TypeFieldDescriptionprivate final Operator
private List<ParameterExpression>
private final Object
Fields inherited from class net.sf.basedb.core.AnnotationRestriction
alias, annotationTypeId, options, valueType
-
Constructor Summary
ConstructorDescriptionAnnotationSimpleRestriction
(String alias, int annotationTypeId, Type valueType, Operator operator, Object value, boolean includePrimary, boolean includeInherited) Deprecated.AnnotationSimpleRestriction
(String alias, int annotationTypeId, Type valueType, Operator operator, List<Object> values, boolean includePrimary, boolean includeInherited) Deprecated.AnnotationSimpleRestriction
(String alias, AnnotationType annotationType, Operator operator, Object value, boolean includePrimary, boolean includeInherited) Deprecated.AnnotationSimpleRestriction
(String alias, AnnotationType annotationType, Operator operator, Object value, AnnotationRestriction.Options options) Create a new annotation restriction using a simple expression:annotation operator value
.AnnotationSimpleRestriction
(String alias, AnnotationType annotationType, Operator operator, List<Object> values, AnnotationRestriction.Options options) Creates a new annotation restriction for a specificvalueType
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
This restriction is equal to another AnnotationSimpleRestriction if they have the same annotation type, operator, list of values and inheritance setting.(package private) String
getRestrictionSql
(Query query, DbControl dc) Get an SQL fragment that includes the actual restriction.int
hashCode()
(package private) void
setRestrictionParameters
(NativeQuery<?> query) Set the value for all parameters defined in the SQL fragment returned byAnnotationRestriction.getRestrictionSql(Query, DbControl)
.Methods inherited from class net.sf.basedb.core.AnnotationRestriction
getChildren, maybeEquals, notAmongSelected, toQl
-
Field Details
-
operator
-
value
-
values
-
parameters
-
-
Constructor Details
-
AnnotationSimpleRestriction
@Deprecated public AnnotationSimpleRestriction(String alias, AnnotationType annotationType, Operator operator, Object value, boolean includePrimary, boolean includeInherited) throws InvalidDataException Deprecated.- Throws:
InvalidDataException
- Since:
- 3.5
-
AnnotationSimpleRestriction
public AnnotationSimpleRestriction(String alias, AnnotationType annotationType, Operator operator, Object value, AnnotationRestriction.Options options) throws InvalidDataException Create a new annotation restriction using a simple expression:annotation operator value
.- Parameters:
alias
- The alias of a joined item where the annotations are located or null to use the root entity of the queryannotationType
- The annotation type to use in the queryoperator
- The operator, it must be one of the expression operators, EQ, NEQ, etc., not a boolean operator, AND, OR, etc.value
- The value to use in the query, it must be of the correct value type for the annotation as defined by theAnnotationType.getValueType()
propertyoptions
- Options that specify which annotations to consider when searching- Throws:
InvalidDataException
- If any of the parameters are null or not follow the rules above.- Since:
- 3.11
-
AnnotationSimpleRestriction
public AnnotationSimpleRestriction(String alias, AnnotationType annotationType, Operator operator, List<Object> values, AnnotationRestriction.Options options) throws InvalidDataException Creates a new annotation restriction for a specificvalueType
. The restriction is with a list of values.- Parameters:
alias
- The alias of a joined item where the annotations are located or null to use the root entity of the queryannotationType
- The annotation type to use in the queryoperator
- The operator, it must be one of the expression operators, EQ, NEQ, etc., not a boolean operator, AND, OR, etc.values
- The list of values that should be used in the query, they must be of the correct value type for the annotation as defined by theAnnotationType.getValueType()
property.options
- Options that specify which annotations to consider when searching- Throws:
InvalidDataException
- If any of the parameters are null or not follow the rules above- Since:
- 3.12.3
-
AnnotationSimpleRestriction
@Deprecated public AnnotationSimpleRestriction(String alias, int annotationTypeId, Type valueType, Operator operator, Object value, boolean includePrimary, boolean includeInherited) throws InvalidDataException Deprecated.- Throws:
InvalidDataException
- Since:
- 3.5
-
AnnotationSimpleRestriction
@Deprecated public AnnotationSimpleRestriction(String alias, int annotationTypeId, Type valueType, Operator operator, List<Object> values, boolean includePrimary, boolean includeInherited) throws InvalidDataException Deprecated.- Throws:
InvalidDataException
- Since:
- 3.5
-
-
Method Details
-
getRestrictionSql
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
ThesetRestrictionParameters
method is called to allow the subclass to set the value of the parameters specified in the SQL fragment.- Specified by:
getRestrictionSql
in classAnnotationRestriction
- 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:
-
setRestrictionParameters
Description copied from class:AnnotationRestriction
Set the value for all parameters defined in the SQL fragment returned byAnnotationRestriction.getRestrictionSql(Query, DbControl)
.- Specified by:
setRestrictionParameters
in classAnnotationRestriction
- Parameters:
query
- The HibernateSQLQuery
object which is used to query the database
-
equals
This restriction is equal to another AnnotationSimpleRestriction if they have the same annotation type, operator, list of values and inheritance setting. -
hashCode
public int hashCode()- Overrides:
hashCode
in classAnnotationRestriction
-
AnnotationSimpleRestriction(String, AnnotationType, Operator, Object, AnnotationRestriction.Options)
instead