|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hdpagination.dataaccess.support.NamedParamRestrictions
public final class NamedParamRestrictions
This class provides static factory methods to produce an object of NamedParamRestriction.
Typically, these factory methods are called when calling
HBN3QueryCallbackNamedParamWrapper.addRestriction(NamedParamRestriction) or
JPAQueryCallbackNamedParamWrapper.addRestriction(NamedParamRestriction).
A sample code is as follows:
HBN3QueryCallbackNamedParamWrapper callback = HBN3QueryCallbackNamedParamWrapper.newInstance("from ProductVO p")
.addRestriction( NamedParamRestrictions.eq("prodNo", "prodNo", crit.getProdNo()) )
.addRestriction( NamedParamRestrictions.contains("madeIn", "madeIn", crit.getMadeIn()) );
One generic rule applied to all the static factory methods is:
paramValue is java.lang.String, it returns null when the paramValue is null or blank.paramValue is of other types, it returns null when the paramValue is null.
If the Restriction object passed to the method
HBN3QueryCallbackNamedParamWrapper.addRestriction(NamedParamRestriction) or
JPAQueryCallbackNamedParamWrapper.addRestriction(NamedParamRestriction)
is null, the restriction will not be added.
The benefit of doing this way is you can avoid IF ELSE check in your code. Consequently, the code is much neater.
| Method Summary | |
|---|---|
static NamedParamRestriction |
contains(java.lang.String column,
java.lang.String paramName,
java.lang.String paramValue)
Apply "LIKE" constraint ( [column] like :[paramName]). |
static NamedParamRestriction |
endsWith(java.lang.String column,
java.lang.String paramName,
java.lang.String paramValue)
Apply "LIKE" constraint ( [column] like :[paramName]). |
static NamedParamRestriction |
eq(java.lang.String column,
java.lang.String paramName,
java.lang.Object paramValue)
Apply "equal" constraint ( [column] = :[paramName]). |
static NamedParamRestriction |
ge(java.lang.String column,
java.lang.String paramName,
java.lang.Object paramValue)
Apply "greater than or equal" constraint ( [column] >= :[paramName]). |
static NamedParamRestriction |
gt(java.lang.String column,
java.lang.String paramName,
java.lang.Object paramValue)
Apply "great than" constraint ( [column] > :[paramName]). |
static NamedParamRestriction |
le(java.lang.String column,
java.lang.String paramName,
java.lang.Object paramValue)
Apply "less than or equal" constraint ( [column] <= :[paramName]). |
static NamedParamRestriction |
lt(java.lang.String column,
java.lang.String paramName,
java.lang.Object paramValue)
Apply "less than" constraint ( [column] < :[paramName]). |
static NamedParamRestriction |
startsWith(java.lang.String column,
java.lang.String paramName,
java.lang.String paramValue)
Apply "LIKE" constraint ( [column] like :[paramName]). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static NamedParamRestriction eq(java.lang.String column,
java.lang.String paramName,
java.lang.Object paramValue)
[column] = :[paramName]).
If the value of parameter (argument paramValue) is null, then return null. It also returns null if the value of parameter
(with the type of java.lang.String) is blank.
column - The column (before =) in the clause fragment. It can not be null or empty.paramName - In Hibernate or JPA query, mamed query parameters are tokens of the form :name in the query string. Here, name (":" excluded)
will be replaced by the value of this argument. For example, if the argument column is "madeIn" and the argument paramName is "country",
then the generated WHERE clause fragment will be "madeIn = :country".
This argument can not be null or empty.paramValue - actual value of the parameter.
public static NamedParamRestriction gt(java.lang.String column,
java.lang.String paramName,
java.lang.Object paramValue)
[column] > :[paramName]).
If the value of parameter (argument paramValue) is null, then return null. It also returns null if the value of parameter
(with the type of java.lang.String) is blank.
column - The column (before >) in the clause fragment. It can not be null or empty.paramName - In Hibernate or JPA query, mamed query parameters are tokens of the form :name in the query string. Here, name (":" excluded)
will be replaced by the value of this argument. For example, if the argument column is "price" and the argument paramName is "priceFrom",
then the generated WHERE clause fragment will be "price > :priceFrom".
This argument can not be null or empty.paramValue - actual value of the parameter.
public static NamedParamRestriction ge(java.lang.String column,
java.lang.String paramName,
java.lang.Object paramValue)
[column] >= :[paramName]).
If the value of parameter (argument paramValue) is null, then return null. It also returns null if the value of parameter
(with the type of java.lang.String) is blank.
column - The column (before >=) in the clause fragment. It can not be null or empty.paramName - In Hibernate or JPA query, mamed query parameters are tokens of the form :name in the query string. Here, name (":" excluded)
will be replaced by the value of this argument. For example, if the argument column is "price" and the argument paramName is "priceFrom",
then the generated WHERE clause fragment will be "price >= :priceFrom".
This argument can not be null or empty.paramValue - actual value of the parameter.
public static NamedParamRestriction lt(java.lang.String column,
java.lang.String paramName,
java.lang.Object paramValue)
[column] < :[paramName]).
If the value of parameter (argument paramValue) is null, then return null. It also returns null if the value of parameter
(with the type of java.lang.String) is blank.
column - The column (before <) in the clause fragment. It can not be null or empty.paramName - In Hibernate or JPA query, mamed query parameters are tokens of the form :name in the query string. Here, name (":" excluded)
will be replaced by the value of this argument. For example, if the argument column is "price" and the argument paramName is "priceTo",
then the generated WHERE clause fragment will be "price < :priceTo".
This argument can not be null or empty.paramValue - actual value of the parameter.
public static NamedParamRestriction le(java.lang.String column,
java.lang.String paramName,
java.lang.Object paramValue)
[column] <= :[paramName]).
If the value of parameter (argument paramValue) is null, then return null. It also returns null if the value of parameter
(with the type of java.lang.String) is blank.
column - The column (before <=) in the clause fragment. It can not be null or empty.paramName - In Hibernate or JPA query, mamed query parameters are tokens of the form :name in the query string. Here, name (":" excluded)
will be replaced by the value of this argument. For example, if the argument column is "price" and the argument paramName is "priceTo",
then the generated WHERE clause fragment will be "price <= :priceTo".
This argument can not be null or empty.paramValue - actual value of the parameter.
public static NamedParamRestriction contains(java.lang.String column,
java.lang.String paramName,
java.lang.String paramValue)
[column] like :[paramName]). The actual binding parameter value is %paramValue%.
If the value of parameter (argument paramValue) is null, then return null. It also returns null if the value of parameter
(with the type of java.lang.String) is blank.
column - The column (before like) in the clause fragmentparamName - In Hibernate or JPA query, mamed query parameters are tokens of the form :name in the query string. Here, name (":" excluded)
will be replaced by the value of this argument. For example, if the argument column is "description" and the argument paramName is "desc",
then the generated WHERE clause fragment will be "description LIKE :desc".
This argument can not be null or empty.paramValue - The actual binding parameter value will be %paramValue%.
public static NamedParamRestriction startsWith(java.lang.String column,
java.lang.String paramName,
java.lang.String paramValue)
[column] like :[paramName]). The actual binding parameter value is paramValue%.
If the value of parameter (argument paramValue) is null, then return null. It also returns null if the value of parameter
(with the type of java.lang.String) is blank.
column - The column (before like) in the clause fragmentparamName - In Hibernate or JPA query, mamed query parameters are tokens of the form :name in the query string. Here, name (":" excluded)
will be replaced by the value of this argument. For example, if the argument column is "description" and the argument paramName is "desc",
then the generated WHERE clause fragment will be "description LIKE :desc".
This argument can not be null or empty.paramValue - The actual binding parameter value will be paramValue%.
public static NamedParamRestriction endsWith(java.lang.String column,
java.lang.String paramName,
java.lang.String paramValue)
[column] like :[paramName]). The actual binding parameter value is %paramValue.
If the value of parameter (argument paramValue) is null, then return null. It also returns null if the value of parameter
(with the type of java.lang.String) is blank.
column - The column (before like) in the clause fragmentparamName - In Hibernate or JPA query, mamed query parameters are tokens of the form :name in the query string. Here, name (":" excluded)
will be replaced by the value of this argument. For example, if the argument column is "description" and the argument paramName is "desc",
then the generated WHERE clause fragment will be "description LIKE :desc".
This argument can not be null or empty.paramValue - The actual binding parameter value will be %paramValue.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||