com.healthmarketscience.sqlbuilder
Class CustomSql

java.lang.Object
  extended by com.healthmarketscience.common.util.AppendeeObject
      extended by com.healthmarketscience.sqlbuilder.SqlObject
          extended by com.healthmarketscience.sqlbuilder.CustomSql
All Implemented Interfaces:
Appendee

public class CustomSql
extends SqlObject

Outputs the given object as is (can be used to insert any custom SQL into a statement).

Example:

 String selectQuery =
   (new SelectQuery())
   .addCustomColumns(new CustomSql("foo"),
                     new CustomSql("baz"),
                     new CustomSql("buzz"))
   .addCustomJoin(SelectQuery.JoinType.INNER_JOIN,
                  new CustomSql("table1"), new CustomSql("table2"),
                  BinaryCondition.equalTo(
                    new CustomSql("table1.id"), new CustomSql("table2.id")))
   .addCustomOrderings(new CustomSql("foo"))
   .validate().toString();

 // Output:
 SELECT foo,baz,buzz FROM table1 INNER JOIN table2 ON (table1.id = table2.id) ORDER BY foo

Author:
James Ahlborn
See Also:
dbspec database model

Field Summary
 
Fields inherited from class com.healthmarketscience.sqlbuilder.SqlObject
ALL_SYMBOL, NULL_VALUE, QUESTION_MARK
 
Constructor Summary
CustomSql(Object obj)
           
 
Method Summary
 void appendTo(AppendableExt app)
           
protected  void collectSchemaObjects(ValidationContext vContext)
          Used during Query.validate() calls to collect the dbschema objects referenced in a query.
 
Methods inherited from class com.healthmarketscience.sqlbuilder.SqlObject
collectSchemaObjects, doValidate, toString
 
Methods inherited from class com.healthmarketscience.common.util.AppendeeObject
toString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CustomSql

public CustomSql(Object obj)
Method Detail

collectSchemaObjects

protected void collectSchemaObjects(ValidationContext vContext)
Description copied from class: SqlObject
Used during Query.validate() calls to collect the dbschema objects referenced in a query. Any subclass of this class should add all referenced tables and columns to the appropriate collections.

Specified by:
collectSchemaObjects in class SqlObject
Parameters:
vContext - handle to the current validation context

appendTo

public void appendTo(AppendableExt app)
              throws IOException
Specified by:
appendTo in interface Appendee
Overrides:
appendTo in class AppendeeObject
Throws:
IOException


Copyright © 2006–2017 Health Market Science. All rights reserved.