org.datanucleus.store.rdbms.sql
Class SQLText

java.lang.Object
  extended by org.datanucleus.store.rdbms.sql.SQLText

public class SQLText
extends java.lang.Object

Representation of a snippet of an SQL statement. May contain parameters. A 'parameter' in this context is an input parameter to the query (which will map on to a JDBC '?' in the resultant SQL). Call "applyParametersToStatement()" to set the parameter values in the PreparedStatement.


Constructor Summary
SQLText()
          Constructor
SQLText(java.lang.String initialStatementText)
          Constructor
 
Method Summary
 SQLText append(char c)
          Append a char
 SQLText append(SQLExpression expr)
          Append an SQLExpression.
 SQLText append(SQLStatement stmt)
          Append an SQLStatement.
 SQLText append(SQLText st)
          Append a StatementText
 SQLText append(java.lang.String s)
          Append a char
 SQLText appendParameter(org.datanucleus.store.mapped.mapping.JavaTypeMapping mapping, java.lang.Object value)
          Append a parameter.
 void applyParametersToStatement(org.datanucleus.ObjectManager om, java.sql.PreparedStatement ps)
          Method to set the parameters in the supplied PreparedStatement using their mappings and provided values.
 void clearStatement()
          Convenience method to reset the SQL for the statement.
 void encloseInParentheses()
          Whether to enclose this statement within parentheses
 SQLText postpend(java.lang.String s)
          Set a String to the end of the statement.
 java.lang.String toSQL()
          Accessor for the SQL of the statement.
 java.lang.String toString()
          Accessor for the string form of the statement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SQLText

public SQLText()
Constructor


SQLText

public SQLText(java.lang.String initialStatementText)
Constructor

Parameters:
initialStatementText -
Method Detail

clearStatement

public void clearStatement()
Convenience method to reset the SQL for the statement. This is used when updating an expression internally, and need to regenerate the statement.


encloseInParentheses

public void encloseInParentheses()
Whether to enclose this statement within parentheses


postpend

public SQLText postpend(java.lang.String s)
Set a String to the end of the statement.

Parameters:
s - the string
Returns:
the StatementText

append

public SQLText append(char c)
Append a char

Parameters:
c - the char
Returns:
the StatementText

append

public SQLText append(java.lang.String s)
Append a char

Parameters:
s - the String
Returns:
the StatementText

append

public SQLText append(SQLStatement stmt)
Append an SQLStatement.

Parameters:
stmt - the SQL Statement
Returns:
the SQLText

append

public SQLText append(SQLText st)
Append a StatementText

Parameters:
st - the StatementText
Returns:
the StatementText

append

public SQLText append(SQLExpression expr)
Append an SQLExpression.

Parameters:
expr - the SQLExpression
Returns:
the StatementText

appendParameter

public SQLText appendParameter(org.datanucleus.store.mapped.mapping.JavaTypeMapping mapping,
                               java.lang.Object value)
Append a parameter.

Parameters:
mapping - the mapping
value - the parameter value
Returns:
the StatementText

applyParametersToStatement

public void applyParametersToStatement(org.datanucleus.ObjectManager om,
                                       java.sql.PreparedStatement ps)
Method to set the parameters in the supplied PreparedStatement using their mappings and provided values. TODO Input parameters don't provide a value so should omit

Parameters:
om - ObjectManager
ps - The PreparedStatement

toSQL

public java.lang.String toSQL()
Accessor for the SQL of the statement.

Returns:
The SQL text

toString

public java.lang.String toString()
Accessor for the string form of the statement.

Overrides:
toString in class java.lang.Object
Returns:
String form of the statement


Copyright © 2009. All Rights Reserved.