mondrian.spi.impl
Class DerbyDialect

java.lang.Object
  extended by mondrian.spi.impl.JdbcDialectImpl
      extended by mondrian.spi.impl.DerbyDialect
All Implemented Interfaces:
Dialect

public class DerbyDialect
extends JdbcDialectImpl

Implementation of Dialect for the Apache Derby database.

Since:
Nov 23, 2008
Version:
$Id: //open/mondrian/src/main/mondrian/spi/impl/DerbyDialect.java#4 $
Author:
jhyde

Nested Class Summary
 
Nested classes/interfaces inherited from interface mondrian.spi.Dialect
Dialect.DatabaseProduct, Dialect.Datatype, Dialect.NullCollation
 
Field Summary
static JdbcDialectFactory FACTORY
           
 
Fields inherited from class mondrian.spi.impl.JdbcDialectImpl
databaseProduct, permitsSelectNotInGroupBy, productVersion
 
Constructor Summary
DerbyDialect(java.sql.Connection connection)
          Creates a DerbyDialect.
 
Method Summary
 boolean allowsMultipleCountDistinct()
          Returns whether this Dialect supports more than one distinct aggregation in the same query.
 java.lang.String generateInline(java.util.List<java.lang.String> columnNames, java.util.List<java.lang.String> columnTypes, java.util.List<java.lang.String[]> valueList)
          Generates a SQL statement to represent an inline dataset.
 java.lang.String generateOrderItem(java.lang.String expr, boolean nullable, boolean ascending)
          Generates an item for an ORDER BY clause, sorting in the required direction, and ensuring that NULL values collate after all non-NULL values.
protected  void quoteDateLiteral(java.lang.StringBuilder buf, java.lang.String value, java.sql.Date date)
          Helper method for JdbcDialectImpl.quoteDateLiteral(StringBuilder, String).
 boolean requiresAliasForFromQuery()
          Returns whether this Dialect requires subqueries in the FROM clause to have an alias.
 boolean supportsGroupByExpressions()
          Returns whether this Dialect supports expressions in the GROUP BY clause.
 
Methods inherited from class mondrian.spi.impl.JdbcDialectImpl
allowsAs, allowsCompoundCountDistinct, allowsCountDistinct, allowsDdl, allowsDialectSharing, allowsFromQuery, allowsMultipleDistinctSqlMeasures, allowsOrderByAlias, allowsSelectNotInGroupBy, appendHintsAfterFromClause, caseWhenElse, deduceIdentifierQuoteString, deduceMaxColumnNameLength, deduceProductName, deduceProductVersion, deduceReadOnly, deduceSupportedResultSetStyles, deduceSupportsSelectNotInGroupBy, generateInlineForAnsi, generateInlineGeneric, getDatabaseProduct, getMaxColumnNameLength, getNullCollation, getProduct, getQuoteIdentifierString, needsExponent, quote, quoteBooleanLiteral, quoteDateLiteral, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteNumericLiteral, quoteStringLiteral, quoteTimeLiteral, quoteTimestampLiteral, requiresGroupByAlias, requiresOrderByAlias, requiresUnionOrderByExprToBeInSelectClause, requiresUnionOrderByOrdinal, supportsGroupingSets, supportsMultiValueInExpr, supportsOrderByNullsLast, supportsResultSetConcurrency, supportsUnlimitedValueList, toString, toUpper
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FACTORY

public static final JdbcDialectFactory FACTORY
Constructor Detail

DerbyDialect

public DerbyDialect(java.sql.Connection connection)
             throws java.sql.SQLException
Creates a DerbyDialect.

Parameters:
connection - Connection
Throws:
java.sql.SQLException
Method Detail

quoteDateLiteral

protected void quoteDateLiteral(java.lang.StringBuilder buf,
                                java.lang.String value,
                                java.sql.Date date)
Description copied from class: JdbcDialectImpl
Helper method for JdbcDialectImpl.quoteDateLiteral(StringBuilder, String).

Overrides:
quoteDateLiteral in class JdbcDialectImpl
Parameters:
buf - Buffer to append to
value - Value as string
date - Value as date

requiresAliasForFromQuery

public boolean requiresAliasForFromQuery()
Description copied from interface: Dialect
Returns whether this Dialect requires subqueries in the FROM clause to have an alias.

Specified by:
requiresAliasForFromQuery in interface Dialect
Overrides:
requiresAliasForFromQuery in class JdbcDialectImpl
Returns:
whether dialewct requires subqueries to have an alias
See Also:
Dialect.allowsFromQuery()

allowsMultipleCountDistinct

public boolean allowsMultipleCountDistinct()
Description copied from interface: Dialect
Returns whether this Dialect supports more than one distinct aggregation in the same query.

In Derby 10.1,

select couunt(distinct x) from t
is OK, but
select couunt(distinct x), count(distinct y) from t
gives "Multiple DISTINCT aggregates are not supported at this time."

Specified by:
allowsMultipleCountDistinct in interface Dialect
Overrides:
allowsMultipleCountDistinct in class JdbcDialectImpl
Returns:
whether this Dialect supports more than one distinct aggregation in the same query

generateInline

public java.lang.String generateInline(java.util.List<java.lang.String> columnNames,
                                       java.util.List<java.lang.String> columnTypes,
                                       java.util.List<java.lang.String[]> valueList)
Description copied from interface: Dialect
Generates a SQL statement to represent an inline dataset.

For example, for Oracle, generates

 SELECT 1 AS FOO, 'a' AS BAR FROM dual
 UNION ALL
 SELECT 2 AS FOO, 'b' AS BAR FROM dual
 

For ANSI SQL, generates:

 VALUES (1, 'a'), (2, 'b')
 

Specified by:
generateInline in interface Dialect
Overrides:
generateInline in class JdbcDialectImpl
Parameters:
columnNames - List of column names
columnTypes - List of column types ("String" or "Numeric")
valueList - List of rows values
Returns:
SQL string

supportsGroupByExpressions

public boolean supportsGroupByExpressions()
Description copied from interface: Dialect
Returns whether this Dialect supports expressions in the GROUP BY clause. Derby/Cloudscape and Infobright do not.

Specified by:
supportsGroupByExpressions in interface Dialect
Overrides:
supportsGroupByExpressions in class JdbcDialectImpl
Returns:
Whether this Dialect allows expressions in the GROUP BY clause

generateOrderItem

public java.lang.String generateOrderItem(java.lang.String expr,
                                          boolean nullable,
                                          boolean ascending)
Description copied from interface: Dialect
Generates an item for an ORDER BY clause, sorting in the required direction, and ensuring that NULL values collate after all non-NULL values.

By default, generateOrderItem(expr, true) generates "expr ASC" and generateOrderItem(expr, false) generates "expr DESC". But depending on Dialect.getNullCollation() and ascending, there may need to be additional code.

For example, on Oracle, where NULLs collate higher than all other values, generateOrderItem(expr, true) generates "expr ASC" and generateOrderItem(expr, false) generates "expr DESC NULLS LAST".

On MySQL, where NULLs collate lower than all other values, generateOrderItem(expr, true) generates "ISNULL(expr), expr ASC" and generateOrderItem(expr, false) generates "expr DESC".

Specified by:
generateOrderItem in interface Dialect
Overrides:
generateOrderItem in class JdbcDialectImpl
Parameters:
expr - Expression
nullable - Whether expression may have NULL values
ascending - Whether to sort expression ascending
Returns:
Expression modified so that NULL values collate last

Get Mondrian at SourceForge.net. Fast, secure and free Open Source software downloads