Class AnnotationRestriction

    • Field Detail

      • logSql

        private static final org.slf4j.Logger logSql
        Log all SQL statements.
      • debugSqlEnabled

        private static final boolean debugSqlEnabled
        So we don't always have to call logSql.debug()
      • valueType

        final Type valueType
      • annotationTypeId

        final int annotationTypeId
    • Constructor Detail

      • AnnotationRestriction

        @Deprecated
        AnnotationRestriction​(String alias,
                              int annotationTypeId,
                              Type valueType,
                              AnnotationRestriction.Options options)
                       throws InvalidDataException
        Deprecated.
        In 3.11
        Create a new annotation restriction given the id and value type of an annotation. It is not verified that there exists an annotation type with the specified id or that it's value type is the one specified. The only thing that will happen is that the restriction will not match any annotations.
        Parameters:
        annotationTypeId - The id of the annotation type
        valueType - The type of values for annotations
        Throws:
        InvalidDataException
    • Method Detail

      • toQl

        public String toQl​(Query query,
                           DbControl dc)
                    throws BaseException
        Description copied from interface: QueryElement
        Create a query language string of the query element. Use the Query.getQueryType() method to find out which query language is wanted in case the element requires different syntax for different languages.
        Specified by:
        toQl in interface QueryElement
        Parameters:
        query - The query that is about to be executed
        dc - The DbControl object used to execute the query
        Throws:
        BaseException - If there is any other error
      • maybeEquals

        protected Boolean maybeEquals​(Object other)
        Check as many things as possible to try to determine if the other object is equal to this object. This method checks if the other instance is the same instance as this object (returns true), if the other instance is null or not the same class (returns false), if the other instance has a different annotation type, alias or inheritance setting (returns false). Subclasses should do more checks if null is returned.
        Returns:
        TRUE or FALSE if it is certain or null if more checks are needed
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getRestrictionSql

        abstract String getRestrictionSql​(Query query,
                                          DbControl dc)
                                   throws BaseException
        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.
        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(NativeQuery)
      • setRestrictionParameters

        abstract void setRestrictionParameters​(NativeQuery<?> query)
        Set the value for all parameters defined in the SQL fragment returned by getRestrictionSql(Query, DbControl).
        Parameters:
        query - The Hibernate SQLQuery object which is used to query the database
      • notAmongSelected

        boolean notAmongSelected()
        If the main restriction should match items that had annotations among the selected annotation sets, or not.
        Returns:
        FALSE (default) to match the selected annotation sets, TRUE to match the non-selected annotation sets
        Since:
        2.7