2.17.2: 2011-06-17

net.sf.basedb.core
Class AnnotationBetweenRestriction

java.lang.Object
  extended by net.sf.basedb.core.AnnotationRestriction
      extended by net.sf.basedb.core.AnnotationBetweenRestriction
All Implemented Interfaces:
QueryElement, Restriction

public class AnnotationBetweenRestriction
extends AnnotationRestriction

Restricts a query using annotation values between a low and high value.

Version:
2.0
Author:
Nicklas
See Also:
Annotations
Last modified
$Date: 2010-04-21 11:48:29 +0200 (Wed, 21 Apr 2010) $

Field Summary
private  Object highValue
           
private  Object lowValue
           
 
Fields inherited from class net.sf.basedb.core.AnnotationRestriction
alias, annotationTypeId, includeInheriting, valueType
 
Constructor Summary
AnnotationBetweenRestriction(AnnotationType annotationType, Object lowValue, Object highValue, boolean includeInheriting)
          Deprecated. Use AnnotationBetweenRestriction(String, AnnotationType, Object, Object, boolean) instead with alias=null
AnnotationBetweenRestriction(String alias, AnnotationType annotationType, Object lowValue, Object highValue, boolean includeInheriting)
          Create a new annotation restriction.
 
Method Summary
 boolean equals(Object other)
          This restriction is equal to another AnnotationBetweenRestriction if they have the same annotation type, upper and lower bound 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(org.hibernate.SQLQuery query)
          Set the value for all parameters defined in the SQL fragment returned by AnnotationRestriction.getRestrictionSql(Query, DbControl).
 
Methods inherited from class net.sf.basedb.core.AnnotationRestriction
getChildren, maybeEquals, notAmongSelected, toQl
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lowValue

private final Object lowValue

highValue

private final Object highValue
Constructor Detail

AnnotationBetweenRestriction

public AnnotationBetweenRestriction(AnnotationType annotationType,
                                    Object lowValue,
                                    Object highValue,
                                    boolean includeInheriting)
                             throws InvalidDataException
Deprecated. Use AnnotationBetweenRestriction(String, AnnotationType, Object, Object, boolean) instead with alias=null

Create a new annotation restriction.

Throws:
InvalidDataException

AnnotationBetweenRestriction

public AnnotationBetweenRestriction(String alias,
                                    AnnotationType annotationType,
                                    Object lowValue,
                                    Object highValue,
                                    boolean includeInheriting)
                             throws InvalidDataException
Create a new annotation restriction.

Parameters:
alias - The alias of a joined item where the annotations are located or null to use the root entity of the query
annotationType - The annotation type to use in the query
lowValue - The low value to use in the query, it must be of the correct value type for the annotation as defined by the AnnotationType.getValueType() property
highValue - The high value to use in the query, it must be of the correct value type for the annotation as defined by the AnnotationType.getValueType() property
includeInheriting - If items inherting the annotation should be returned by the query or not
Throws:
InvalidDataException - If any of the parameters are null or not follow the rules above.
Since:
2.4
Method Detail

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(org.hibernate.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

equals

public boolean equals(Object other)
This restriction is equal to another AnnotationBetweenRestriction if they have the same annotation type, upper and lower bound and inheritance setting.

Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class AnnotationRestriction

2.17.2: 2011-06-17