2.17.2: 2011-06-17

net.sf.basedb.core.query
Interface Restriction

All Superinterfaces:
QueryElement
All Known Implementing Classes:
AndRestriction, AnnotationBetweenRestriction, AnnotationInRestriction, AnnotationRestriction, AnnotationSimpleRestriction, BetweenRestriction, DynamicRestriction, EqRestriction, GteqRestriction, GtRestriction, HasAnnotationRestriction, HqlExpression, InRestriction, LikeRestriction, LteqRestriction, LtRestriction, NeqRestriction, NotRestriction, OrRestriction, RlikeRestriction, SharedToRestriction

public interface Restriction
extends QueryElement

A restriction query element. This is a query element that can appear in the WHERE and HAVING part of a Query. Typically a restriction consists of a condition which must be true for a row if it should be returned. For example:

SELECT ...
FROM ...
WHERE id = 2

Implementation note! Do not create restrictions that use user input directly in the queries. Always create a parameter (Expressions.parameter(String) and use the Query.setParameter(String, Object, Type) method to specify the value. Using parameters also makes it possible to execute the same query multiple times with different parameter values.

ItemQuery<User> query = User.getQuery();
query.restrict(
   Restrictions.eq(
      Hql.property("name"),
      Expressions.parameter("name")
   )
);

// Generated HQL
SELECT usr
FROM UserData usr
WHERE usr.name = :name

query.setParameter("name", "Nicklas");
List nicklasList = query.list(dc);

query.setParameter("name", "Johan");
List johanList = query.list(dc);

Restrictions can be created by the Restrictions factory class.

Version:
2.0
Author:
Nicklas
See Also:
Restrictions
Last modified
$Date: 2009-04-06 14:52:39 +0200 (Mon, 06 Apr 2009) $

Method Summary
 
Methods inherited from interface net.sf.basedb.core.query.QueryElement
getChildren, toQl
 


2.17.2: 2011-06-17