Package net.sf.basedb.core
Class HasAnnotationRestriction
java.lang.Object
net.sf.basedb.core.AnnotationRestriction
net.sf.basedb.core.HasAnnotationRestriction
- All Implemented Interfaces:
QueryElement
,Restriction
Restricts a query by the presence of absence of an annotation.
- Version:
- 2.7
- 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
Fields inherited from class net.sf.basedb.core.AnnotationRestriction
alias, annotationTypeId, options, valueType
-
Constructor Summary
ConstructorDescriptionHasAnnotationRestriction
(String alias, int annotationTypeId, boolean hasBeenAnnotatated, boolean includePrimary, boolean includeInherited) Deprecated.HasAnnotationRestriction
(String alias, AnnotationType annotationType, boolean hasBeenAnnotatated, boolean includePrimary, boolean includeInheriting) Deprecated.HasAnnotationRestriction
(String alias, AnnotationType annotationType, boolean hasBeenAnnotatated, AnnotationRestriction.Options options) Create a new restriction that checks if an item has been annotatated or not. -
Method Summary
Modifier and TypeMethodDescriptionboolean
This restriction is equal to another HasAnnotationRestriction if they have the same annotation type, inheritance setting and annotation check.(package private) String
getRestrictionSql
(Query query, DbControl dc) Get an SQL fragment that includes the actual restriction.int
hashCode()
(package private) boolean
If the main restriction should match items that had annotations among the selected annotation sets, or not.(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, toQl
-
Field Details
-
hasBeenAnnotatated
private boolean hasBeenAnnotatated
-
-
Constructor Details
-
HasAnnotationRestriction
@Deprecated public HasAnnotationRestriction(String alias, AnnotationType annotationType, boolean hasBeenAnnotatated, boolean includePrimary, boolean includeInheriting) Deprecated.Create a new restriction that checks if an item has been annotatated or not.- 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 queryhasBeenAnnotatated
- TRUE to look for items that has been annotated with the given annotation type, FALSE to look for items that hasn'tincludePrimary
- If items with this annotation as a primary annotation should be returned by the query or notincludeInheriting
- If items inherting the annotation should be returned by the query or not- Since:
- 3.5
-
HasAnnotationRestriction
public HasAnnotationRestriction(String alias, AnnotationType annotationType, boolean hasBeenAnnotatated, AnnotationRestriction.Options options) Create a new restriction that checks if an item has been annotatated or not.- 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 queryhasBeenAnnotatated
- TRUE to look for items that has been annotated with the given annotation type, FALSE to look for items that hasn'toptions
- Options that specify which annotations to consider when searching- Since:
- 3.11
-
HasAnnotationRestriction
@Deprecated public HasAnnotationRestriction(String alias, int annotationTypeId, boolean hasBeenAnnotatated, boolean includePrimary, boolean includeInherited) Deprecated.
-
-
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
-
notAmongSelected
boolean notAmongSelected()Description copied from class:AnnotationRestriction
If the main restriction should match items that had annotations among the selected annotation sets, or not.- Overrides:
notAmongSelected
in classAnnotationRestriction
- Returns:
- FALSE (default) to match the selected annotation sets, TRUE to match the non-selected annotation sets
-
equals
This restriction is equal to another HasAnnotationRestriction if they have the same annotation type, inheritance setting and annotation check. -
hashCode
public int hashCode()- Overrides:
hashCode
in classAnnotationRestriction
-
HasAnnotationRestriction(String, AnnotationType, boolean, AnnotationRestriction.Options)
instead