|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | ||||||||
@Target(value={TYPE,METHOD,FIELD})
@Retention(value=RUNTIME)
@Documented
public @interface DbNumCheckIf a method or field is annotated with this annotation it means that its value must be checked against a database query. The query must return a single result. In general you'd best use a count query, where your return a value which determines whether the value is valid or not.
The check is valid if the query returns the expected value of this annotation. An example, both do the same, one defines the query directly. The other refers to a query defined in the xml configuration file:
@DbNumCheck(refDsId="myDS",query="select count(*) from table x where x.id=${this}")
@DbNumCheck(refDsId="myDS", refQueryId="myQuery")
Note the ${this}, refers to the current METHOD/FIELD it is annotated to (thus its value will be bound).
Finally: You can annotate field/methods with the annotation, but also on a class. If specified on class level it is applied from there (you can add multiple of these constraints in that case, if you wish).
| Required Element Summary | |
|---|---|
java.lang.String |
refDsId
Id of datasource defined in the xml config file for the database extension. |
| Optional Element Summary | |
|---|---|
java.lang.String[] |
applyToGroups
Specify for which groups this annotation must be applied. |
java.lang.String |
customCode
Optional custom code (property from a properties file). |
boolean |
globalMessage
If this annotation's message must be added as global message instead of real validation path. |
long |
maxValue
Must be set when mode() is set to MODE_BETWEEN, this represents the maximum value then (inclusive). |
long |
minValue
Must be set when mode() is set to MODE_BETWEEN, this represents the minimum value then (inclusive). |
int |
mode
The mode the check is in, defaults to equals. |
java.lang.String |
query
Actual sql query to use. |
java.lang.String |
refQueryId
Id of query defined in the xml config file for the database extension. |
long |
value
The value returned by the query (must be int / long). |
| Element Detail |
|---|
public abstract java.lang.String refDsId
public abstract java.lang.String refQueryId
public abstract java.lang.String query
public abstract long value
public abstract long minValue
public abstract long maxValue
public abstract int mode
public abstract java.lang.String customCode
This way you can override the default message if needed.
public abstract java.lang.String[] applyToGroups
Defaults to JvGroup.GROUP_APPLY_ALL
public abstract boolean globalMessage
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | ||||||||