Package org.r10r.sqlify
Class Sqlify.Builder
- java.lang.Object
-
- org.r10r.sqlify.Sqlify.Builder
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <E> EexecuteSelect(Connection connection)Executes a select.intexecuteUpdate(Connection connection)Executes an update (insert, delete statement)<E> EexecuteUpdateAndReturnGeneratedKey(Connection connection)Executes an update (insert, delete statement) and returns the generated key.Sqlify.BuilderparseResultWith(ResultParser<?> resultParser)Sqlify.BuilderwithParameter(String key, Object value)Provide parameters for placeholders in query.
-
-
-
Method Detail
-
withParameter
public Sqlify.Builder withParameter(String key, Object value)
Provide parameters for placeholders in query. For instance "SELECT * FROM table WHERE id = {id} => withParameter("id", 1234L);- Parameters:
key- The key in your SQL query. Written in curly braces inside your SQL.value- The value for that query. If it is an Optional it will be unpacked automatically if it contains a value.- Returns:
- The builder for chaining
-
parseResultWith
public Sqlify.Builder parseResultWith(ResultParser<?> resultParser)
-
executeSelect
public <E> E executeSelect(Connection connection)
Executes a select. Use 'parseResultWith' to specify a parser that will map the result to nice Java objects.- Parameters:
connection- The connection to use for this query.- Returns:
- The result as specified via 'parseResultWith'
-
executeUpdate
public int executeUpdate(Connection connection)
Executes an update (insert, delete statement)- Parameters:
connection- The connection to use for this query.- Returns:
- The number of lines affected by this query.
-
executeUpdateAndReturnGeneratedKey
public <E> E executeUpdateAndReturnGeneratedKey(Connection connection)
Executes an update (insert, delete statement) and returns the generated key. Define the mapping via a ResultParser. For instance if you expect one Long as result you can use parseResultWith(SingleResultParser.of(Long.class))- Parameters:
connection- The connection to use for this query.- Returns:
- The generated key.
-
-