All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sqlg3.annotations.Query Maven / Gradle / Ivy

Go to download

SQLG is a preprocessor and a library that uses code generation to simplify writing JDBC code

There is a newer version: 3.1
Show newest version
package sqlg3.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Annotation for local variables marking QueryPiece to be generated.
 * SQL query is taken from preceding javadoc comments.
 * {@link sqlg3.runtime.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 {@link sqlg3.runtime.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 {@link sqlg3.runtime.QueryBuilder} or methods * like {@link sqlg3.runtime.QueryPiece#add(sqlg3.runtime.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;
 * 
*/ @Retention(RetentionPolicy.SOURCE) @Target(ElementType.LOCAL_VARIABLE) public @interface Query { }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy