|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
@Retention(value=SOURCE) @Target(value=LOCAL_VARIABLE) public @interface Query
Annotation for local variables marking QueryPiece to be generated.
SQL query is taken from preceding javadoc comments.
QueryPiece
can be used to build larger SQL statement from pieces.
Example:
int idParam = ...; /** * WHERE ID = :idParam */ @Query QueryPiece sql1 = null;Preprocessor generates code to encapsulate SQL text and parameters in the
QueryPiece
object.
Note that parameters referenced
in query (as :paramName
) should be accessible as variables in the current scope.
You can use query pieces to build larger queries manually using QueryBuilder
or methods
like QueryPiece.add(sqlg2.db.QueryPiece...)
, but also you can reference query pieces in
javadoc comments used for queries as &piece
, example:
/** * SELECT NAME, VALUE * FROM TABLE * &sql1 */ @Prepare PreparedStatement stmt = null;In this way you can combine multiple pieces into one query. &-substitution works not only for QueryPieces, but also for Strings:
String table = "TABLE"; /** * SELECT NAME, VALUE * FROM &table * &sql1 */ @Query QueryPiece largeQuery = null;
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |