org.outerj.daisy.query.model
Class SqlGenerationContext

java.lang.Object
  extended by org.outerj.daisy.query.model.SqlGenerationContext

public class SqlGenerationContext
extends java.lang.Object

Context object used during the generation of SQL from a daisy query.

The main goal of this class is to keep track of which tables are required by the conditions, thus which tables will need to be joined in the "from" clause of the SQL statement. Next to that, it also contains constants for table and field names so that those aren't scattered around everywhere in the code.


Nested Class Summary
static class SqlGenerationContext.CustomFieldsTable
           
static class SqlGenerationContext.DocsCollectionsTable
          Meta information about the association table between documents and collections.
static class SqlGenerationContext.DocumentsTable
           
static class SqlGenerationContext.DocumentVariantsTable
           
static class SqlGenerationContext.ExtractedLinksTable
           
static class SqlGenerationContext.FieldsTable
           
static class SqlGenerationContext.FieldTypesTable
           
static class SqlGenerationContext.LocksTable
           
static class SqlGenerationContext.PartsTable
           
static class SqlGenerationContext.SummariesTable
           
static interface SqlGenerationContext.Table
           
static class SqlGenerationContext.VersionsTable
          Meta information about the table containing version information.
 
Field Summary
static SqlGenerationContext.ExtractedLinksTable EXTRACTED_LINKS_TABLE
           
static SqlGenerationContext.ExtractedLinksTable EXTRACTED_LINKS_TABLE_INVERSE
           
static SqlGenerationContext.LocksTable LOCKS_TABLE
           
static SqlGenerationContext.PartsTable PARTS_TABLE
           
static SqlGenerationContext.SummariesTable SUMMARIES_TABLE
           
static SqlGenerationContext.VersionsTable VERSIONS_TABLE
          The association table between documents and collections
 
Constructor Summary
SqlGenerationContext(org.outerj.daisy.jdbcutil.JdbcHelper jdbcHelper)
           
 
Method Summary
 void appendDocIdSelectClause(java.lang.StringBuffer sql)
           
 void appendFromClause(java.lang.StringBuffer sql, boolean searchLastVersion)
          Generates the SQL "from" expression based on the requested field table aliases (using getNewFieldsTableAlias()) and joined tables (see needsJoinWithTable(org.outerj.daisy.query.model.SqlGenerationContext.Table)).
 int bindJoins(java.sql.PreparedStatement stmt, int bindPos)
           
 org.outerj.daisy.jdbcutil.JdbcHelper getJdbcHelper()
           
 java.lang.String getNewAliasCounter()
           
 java.lang.String getNewCollectionsTableAlias()
           
 java.lang.String getNewCustomFieldsTableAlias()
           
 java.lang.String getNewFieldsTableAlias()
          Returns a new alias for a join with the "thefields" table, and adds a join with it.
 java.lang.String getNewPartsTableAlias()
           
static java.lang.String getVersionField(boolean searchLastVersion)
           
 void needsJoinWithTable(SqlGenerationContext.Table table)
          Adds a table to join with.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSIONS_TABLE

public static final SqlGenerationContext.VersionsTable VERSIONS_TABLE
The association table between documents and collections


EXTRACTED_LINKS_TABLE

public static final SqlGenerationContext.ExtractedLinksTable EXTRACTED_LINKS_TABLE

EXTRACTED_LINKS_TABLE_INVERSE

public static final SqlGenerationContext.ExtractedLinksTable EXTRACTED_LINKS_TABLE_INVERSE

SUMMARIES_TABLE

public static final SqlGenerationContext.SummariesTable SUMMARIES_TABLE

PARTS_TABLE

public static final SqlGenerationContext.PartsTable PARTS_TABLE

LOCKS_TABLE

public static final SqlGenerationContext.LocksTable LOCKS_TABLE
Constructor Detail

SqlGenerationContext

public SqlGenerationContext(org.outerj.daisy.jdbcutil.JdbcHelper jdbcHelper)
Method Detail

getNewAliasCounter

public java.lang.String getNewAliasCounter()

getJdbcHelper

public org.outerj.daisy.jdbcutil.JdbcHelper getJdbcHelper()

getNewFieldsTableAlias

public java.lang.String getNewFieldsTableAlias()
Returns a new alias for a join with the "thefields" table, and adds a join with it. So no need to call needsJoinWithTable.


getNewCollectionsTableAlias

public java.lang.String getNewCollectionsTableAlias()

getNewCustomFieldsTableAlias

public java.lang.String getNewCustomFieldsTableAlias()

getNewPartsTableAlias

public java.lang.String getNewPartsTableAlias()

needsJoinWithTable

public void needsJoinWithTable(SqlGenerationContext.Table table)
Adds a table to join with. If the same Table object is added a second time, it is ignored. The joins will be performed in the order as added here.


appendDocIdSelectClause

public void appendDocIdSelectClause(java.lang.StringBuffer sql)

bindJoins

public int bindJoins(java.sql.PreparedStatement stmt,
                     int bindPos)
              throws java.sql.SQLException,
                     org.outerj.daisy.repository.query.QueryException
Throws:
java.sql.SQLException
org.outerj.daisy.repository.query.QueryException

appendFromClause

public void appendFromClause(java.lang.StringBuffer sql,
                             boolean searchLastVersion)
Generates the SQL "from" expression based on the requested field table aliases (using getNewFieldsTableAlias()) and joined tables (see needsJoinWithTable(org.outerj.daisy.query.model.SqlGenerationContext.Table)). The documents table is always included.


getVersionField

public static java.lang.String getVersionField(boolean searchLastVersion)


Copyright © -2012 . All Rights Reserved.