|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Restriction
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"); ListnicklasList = query.list(dc); query.setParameter("name", "Johan"); List johanList = query.list(dc);
Restrictions can be created by the Restrictions
factory class.
Restrictions
Method Summary |
---|
Methods inherited from interface net.sf.basedb.core.query.QueryElement |
---|
getChildren, toQl |
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |