Package com.couchbase.client.java.query
Class PrepareStatement
- java.lang.Object
-
- com.couchbase.client.java.query.PrepareStatement
-
- All Implemented Interfaces:
SerializableStatement,Statement,Serializable
public class PrepareStatement extends Object implements SerializableStatement
A PREPAREStatementthat wraps another Statement in order to send it to the server and produce aPreparedPayload.- Since:
- 2.1
- Author:
- Simon Baslé
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringPREPARE_PREFIXa prefix to be used in order to prepare a named query plan for a statement
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StatementoriginalStatement()static PrepareStatementprepare(Statement statement)Construct aPrepareStatementfrom a select-likeStatement.static PrepareStatementprepare(Statement statement, String preparedName)Construct aPrepareStatementfrom a select-likeStatementand give it a name.static PrepareStatementprepare(String statement)Construct aPrepareStatementfrom a statement inStringformat.StringpreparedName()StringtoString()
-
-
-
Field Detail
-
PREPARE_PREFIX
public static final String PREPARE_PREFIX
a prefix to be used in order to prepare a named query plan for a statement- See Also:
- Constant Field Values
-
-
Method Detail
-
originalStatement
public Statement originalStatement()
-
preparedName
public String preparedName()
-
prepare
public static PrepareStatement prepare(Statement statement)
Construct aPrepareStatementfrom a select-likeStatement. Note that passing aPrepareStatementwill return it directly, whereas passing aPreparedPayloadwill reuse thePreparedPayload.preparedName().- Parameters:
statement- theStatementto prepare.- Returns:
- the prepared statement.
- Throws:
IllegalArgumentException- when statement cannot be prepared.
-
prepare
public static PrepareStatement prepare(Statement statement, String preparedName)
Construct aPrepareStatementfrom a select-likeStatementand give it a name. Note that passing aPrepareStatementor aPreparedPayloadwill reuse theoriginal statementbut use the given name.- Parameters:
statement- theStatementto prepare.preparedName- the name to give to the prepared statement- Returns:
- the prepared statement.
- Throws:
IllegalArgumentException- when statement cannot be prepared.
-
prepare
public static PrepareStatement prepare(String statement)
Construct aPrepareStatementfrom a statement inStringformat. Statement shouldn't begin with "PREPARE", otherwise a syntax error may be returned by the server.- Parameters:
statement- the statement to prepare (not starting with "PREPARE").- Returns:
- the prepared statement.
- Throws:
NullPointerException- when statement is null.
-
-