add some Javadoc, and rename a class
This commit is contained in:
parent
c072ee9cb2
commit
ccee58add8
|
@ -308,7 +308,7 @@ public abstract class AbstractHANADialect extends Dialect {
|
||||||
functionFactory.secondsBetween();
|
functionFactory.secondsBetween();
|
||||||
functionFactory.format_toVarchar();
|
functionFactory.format_toVarchar();
|
||||||
functionFactory.currentUtcdatetimetimestamp();
|
functionFactory.currentUtcdatetimetimestamp();
|
||||||
functionFactory.everyAny_sumCaseCase();
|
functionFactory.everyAny_minMaxCase();
|
||||||
functionFactory.bitLength_pattern( "length(to_binary(?1))*8" );
|
functionFactory.bitLength_pattern( "length(to_binary(?1))*8" );
|
||||||
|
|
||||||
functionFactory.listagg_stringAgg( "varchar" );
|
functionFactory.listagg_stringAgg( "varchar" );
|
||||||
|
|
|
@ -885,7 +885,8 @@ public abstract class Dialect implements ConversionContext {
|
||||||
queryEngine.getSqmFunctionRegistry().register( "extract",
|
queryEngine.getSqmFunctionRegistry().register( "extract",
|
||||||
new ExtractFunction( this ) );
|
new ExtractFunction( this ) );
|
||||||
|
|
||||||
//comparison functions supported on every known database
|
//comparison functions supported on most databases, emulated on others
|
||||||
|
//using a case expression
|
||||||
|
|
||||||
functionFactory.leastGreatest();
|
functionFactory.leastGreatest();
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ public class OracleDialect extends Dialect {
|
||||||
functionFactory.characterLength_length( SqlAstNodeRenderingMode.DEFAULT );
|
functionFactory.characterLength_length( SqlAstNodeRenderingMode.DEFAULT );
|
||||||
functionFactory.addMonths();
|
functionFactory.addMonths();
|
||||||
functionFactory.monthsBetween();
|
functionFactory.monthsBetween();
|
||||||
functionFactory.everyAny_sumCaseCase();
|
functionFactory.everyAny_minMaxCase();
|
||||||
|
|
||||||
functionFactory.median();
|
functionFactory.median();
|
||||||
functionFactory.stddev();
|
functionFactory.stddev();
|
||||||
|
|
|
@ -218,7 +218,7 @@ public class SQLServerDialect extends AbstractTransactSQLDialect {
|
||||||
functionFactory.avg_castingNonDoubleArguments( this, SqlAstNodeRenderingMode.DEFAULT );
|
functionFactory.avg_castingNonDoubleArguments( this, SqlAstNodeRenderingMode.DEFAULT );
|
||||||
|
|
||||||
functionFactory.truncate_round();
|
functionFactory.truncate_round();
|
||||||
functionFactory.everyAny_sumIif();
|
functionFactory.everyAny_minMaxIif();
|
||||||
functionFactory.bitLength_pattern( "datalength(?1) * 8" );
|
functionFactory.bitLength_pattern( "datalength(?1) * 8" );
|
||||||
|
|
||||||
if ( getVersion().isSameOrAfter( 10 ) ) {
|
if ( getVersion().isSameOrAfter( 10 ) ) {
|
||||||
|
|
|
@ -220,7 +220,7 @@ public class SybaseDialect extends AbstractTransactSQLDialect {
|
||||||
functionFactory.locate_charindex();
|
functionFactory.locate_charindex();
|
||||||
|
|
||||||
functionFactory.replace_strReplace();
|
functionFactory.replace_strReplace();
|
||||||
functionFactory.everyAny_sumCaseCase();
|
functionFactory.everyAny_minMaxCase();
|
||||||
functionFactory.bitLength_pattern( "datalength(?1) * 8" );
|
functionFactory.bitLength_pattern( "datalength(?1) * 8" );
|
||||||
|
|
||||||
queryEngine.getSqmFunctionRegistry().register( "timestampadd",
|
queryEngine.getSqmFunctionRegistry().register( "timestampadd",
|
||||||
|
|
|
@ -19,6 +19,8 @@ import org.hibernate.sql.ast.tree.SqlAstNode;
|
||||||
import static org.hibernate.query.sqm.produce.function.FunctionParameterType.COMPARABLE;
|
import static org.hibernate.query.sqm.produce.function.FunctionParameterType.COMPARABLE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Some databases don't have a function like {@code least()} or {@code greatest()},
|
||||||
|
* and on those platforms we emulate the function using {@code case}.
|
||||||
*
|
*
|
||||||
* @author Christian Beikov
|
* @author Christian Beikov
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -23,6 +23,10 @@ import org.hibernate.sql.ast.tree.expression.CastTarget;
|
||||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* ANSI SQL-inspired {@code cast()} function, where the target types
|
||||||
|
* are enumerated by {@link CastType}, and portability is achieved
|
||||||
|
* by delegating to {@link Dialect#castPattern(CastType, CastType)}.
|
||||||
|
*
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
*/
|
*/
|
||||||
public class CastFunction extends AbstractSqmSelfRenderingFunctionDescriptor {
|
public class CastFunction extends AbstractSqmSelfRenderingFunctionDescriptor {
|
||||||
|
|
|
@ -24,6 +24,8 @@ import java.util.List;
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The HQL {@code str()} function is now considered a synonym for {@code cast(x as String)}.
|
||||||
|
*
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
*/
|
*/
|
||||||
public class CastStrEmulation
|
public class CastStrEmulation
|
||||||
|
|
|
@ -812,7 +812,7 @@ public class CommonFunctionFactory {
|
||||||
* These are aggregate functions taking one argument,
|
* These are aggregate functions taking one argument,
|
||||||
* for SQL Server.
|
* for SQL Server.
|
||||||
*/
|
*/
|
||||||
public void everyAny_sumIif() {
|
public void everyAny_minMaxIif() {
|
||||||
functionRegistry.register( "every",
|
functionRegistry.register( "every",
|
||||||
new SQLServerEveryAnyEmulation( typeConfiguration, true ) );
|
new SQLServerEveryAnyEmulation( typeConfiguration, true ) );
|
||||||
functionRegistry.register( "any",
|
functionRegistry.register( "any",
|
||||||
|
@ -824,11 +824,11 @@ public class CommonFunctionFactory {
|
||||||
* These are aggregate functions taking one argument,
|
* These are aggregate functions taking one argument,
|
||||||
* for Oracle and Sybase.
|
* for Oracle and Sybase.
|
||||||
*/
|
*/
|
||||||
public void everyAny_sumCaseCase() {
|
public void everyAny_minMaxCase() {
|
||||||
functionRegistry.register( "every",
|
functionRegistry.register( "every",
|
||||||
new CaseWhenEveryAnyEmulation( typeConfiguration, true ) );
|
new MinMaxCaseEveryAnyEmulation( typeConfiguration, true ) );
|
||||||
functionRegistry.register( "any",
|
functionRegistry.register( "any",
|
||||||
new CaseWhenEveryAnyEmulation( typeConfiguration, false ) );
|
new MinMaxCaseEveryAnyEmulation( typeConfiguration, false ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,6 +17,9 @@ import org.hibernate.type.BasicType;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* A "function" with no parameters that returns the current date, time, or timestamp.
|
||||||
|
* For example, {@code current_date}.
|
||||||
|
*
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
*/
|
*/
|
||||||
public class CurrentFunction
|
public class CurrentFunction
|
||||||
|
|
|
@ -23,6 +23,13 @@ import org.hibernate.type.spi.TypeConfiguration;
|
||||||
import static org.hibernate.query.sqm.produce.function.FunctionParameterType.BOOLEAN;
|
import static org.hibernate.query.sqm.produce.function.FunctionParameterType.BOOLEAN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Most databases don't have a function like {@code every()} or {@code any()}.
|
||||||
|
* On many platforms we emulate the function using {@code sum()} together with
|
||||||
|
* {@code case}.
|
||||||
|
*
|
||||||
|
* @see MinMaxCaseEveryAnyEmulation
|
||||||
|
* @see SQLServerEveryAnyEmulation
|
||||||
|
*
|
||||||
* @author Jan Schatteman
|
* @author Jan Schatteman
|
||||||
*/
|
*/
|
||||||
public class EveryAnyEmulation extends AbstractSqmSelfRenderingFunctionDescriptor {
|
public class EveryAnyEmulation extends AbstractSqmSelfRenderingFunctionDescriptor {
|
||||||
|
|
|
@ -33,6 +33,10 @@ import static org.hibernate.query.sqm.produce.function.FunctionParameterType.TEM
|
||||||
import static org.hibernate.query.sqm.produce.function.StandardFunctionReturnTypeResolvers.useArgType;
|
import static org.hibernate.query.sqm.produce.function.StandardFunctionReturnTypeResolvers.useArgType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* ANSI SQL-inspired {@code extract()} function, where the date/time fields
|
||||||
|
* are enumerated by {@link TemporalUnit}, and portability is achieved
|
||||||
|
* by delegating to {@link Dialect#extractPattern(TemporalUnit)}.
|
||||||
|
*
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
*/
|
*/
|
||||||
public class ExtractFunction
|
public class ExtractFunction
|
||||||
|
|
|
@ -35,6 +35,9 @@ import static org.hibernate.query.sqm.produce.function.FunctionParameterType.INT
|
||||||
import static org.hibernate.query.sqm.produce.function.FunctionParameterType.STRING;
|
import static org.hibernate.query.sqm.produce.function.FunctionParameterType.STRING;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Emulates the ANSI SQL-standard {@code overlay()} function using {@code insert()}
|
||||||
|
* {@code substring()}, and {@code concat()}.
|
||||||
|
*
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
*/
|
*/
|
||||||
public class InsertSubstringOverlayEmulation
|
public class InsertSubstringOverlayEmulation
|
||||||
|
|
|
@ -22,6 +22,8 @@ import java.util.List;
|
||||||
import static org.hibernate.query.sqm.produce.function.FunctionParameterType.STRING;
|
import static org.hibernate.query.sqm.produce.function.FunctionParameterType.STRING;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Emulates the ANSI SQL-standard {@code position()} function using {@code locate()}.
|
||||||
|
*
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
*/
|
*/
|
||||||
public class LocatePositionEmulation extends AbstractSqmFunctionDescriptor {
|
public class LocatePositionEmulation extends AbstractSqmFunctionDescriptor {
|
||||||
|
|
|
@ -27,6 +27,12 @@ import static org.hibernate.query.sqm.produce.function.FunctionParameterType.STR
|
||||||
import static org.hibernate.query.sqm.produce.function.FunctionParameterType.TRIM_SPEC;
|
import static org.hibernate.query.sqm.produce.function.FunctionParameterType.TRIM_SPEC;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* HQL function inspired by the {@linkplain TrimFunction ANSI SQL trim function},
|
||||||
|
* with a funny syntax involving a {@link TrimSpec}. Emulated using {@code rpad()}
|
||||||
|
* and {@code lpad()} or by equivalent emulations of those functions.
|
||||||
|
* <p>
|
||||||
|
* For example, {@code pad(text with 5 leading ' ')}.
|
||||||
|
*
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
*/
|
*/
|
||||||
public class LpadRpadPadEmulation
|
public class LpadRpadPadEmulation
|
||||||
|
|
|
@ -22,13 +22,19 @@ import org.hibernate.type.StandardBasicTypes;
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Most databases don't have a function like {@code every()} or {@code any()}.
|
||||||
|
* On some platforms we emulate the function using {@code min()} or {@code max()}
|
||||||
|
* together with {@code case}.
|
||||||
|
*
|
||||||
|
* @see EveryAnyEmulation
|
||||||
|
*
|
||||||
* @author Jan Schatteman
|
* @author Jan Schatteman
|
||||||
*/
|
*/
|
||||||
public class CaseWhenEveryAnyEmulation extends AbstractSqmSelfRenderingFunctionDescriptor {
|
public class MinMaxCaseEveryAnyEmulation extends AbstractSqmSelfRenderingFunctionDescriptor {
|
||||||
|
|
||||||
private final boolean every;
|
private final boolean every;
|
||||||
|
|
||||||
public CaseWhenEveryAnyEmulation(TypeConfiguration typeConfiguration, boolean every) {
|
public MinMaxCaseEveryAnyEmulation(TypeConfiguration typeConfiguration, boolean every) {
|
||||||
super(
|
super(
|
||||||
every ? "every" : "any",
|
every ? "every" : "any",
|
||||||
FunctionKind.AGGREGATE,
|
FunctionKind.AGGREGATE,
|
|
@ -19,6 +19,7 @@ import org.hibernate.sql.ast.tree.SqlAstNode;
|
||||||
import static org.hibernate.query.sqm.produce.function.FunctionParameterType.COMPARABLE;
|
import static org.hibernate.query.sqm.produce.function.FunctionParameterType.COMPARABLE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @see CaseLeastGreatestEmulation
|
||||||
*
|
*
|
||||||
* @author Christian Beikov
|
* @author Christian Beikov
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -23,6 +23,12 @@ import org.hibernate.type.spi.TypeConfiguration;
|
||||||
import static org.hibernate.query.sqm.produce.function.FunctionParameterType.BOOLEAN;
|
import static org.hibernate.query.sqm.produce.function.FunctionParameterType.BOOLEAN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* SQL Server doesn't have a function like {@code every()} or {@code any()}.
|
||||||
|
* We emulate the function using {@code min()} or {@code max()} together with
|
||||||
|
* {@code iif()}.
|
||||||
|
*
|
||||||
|
* @see EveryAnyEmulation
|
||||||
|
*
|
||||||
* @author Jan Schatteman
|
* @author Jan Schatteman
|
||||||
*/
|
*/
|
||||||
public class SQLServerEveryAnyEmulation extends AbstractSqmSelfRenderingFunctionDescriptor {
|
public class SQLServerEveryAnyEmulation extends AbstractSqmSelfRenderingFunctionDescriptor {
|
||||||
|
|
|
@ -22,8 +22,9 @@ import org.hibernate.type.StandardBasicTypes;
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A special function that renders to the T-SQL "str" function if more than a single argument is given,
|
* A special function that renders a T-SQL {@code str()} function
|
||||||
* otherwise renders a cast expression like {@link CastStrEmulation}.
|
* if more than a single argument is given, or otherwise renders
|
||||||
|
* a {@code cast()} expression just like {@link CastStrEmulation}.
|
||||||
*
|
*
|
||||||
* @author Christian Beikov
|
* @author Christian Beikov
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -29,6 +29,12 @@ import static org.hibernate.query.sqm.produce.function.FunctionParameterType.TRI
|
||||||
import static org.hibernate.query.sqm.produce.function.FunctionParameterType.STRING;
|
import static org.hibernate.query.sqm.produce.function.FunctionParameterType.STRING;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* ANSI SQL-standard {@code trim()} function, which has a funny syntax
|
||||||
|
* involving a {@link TrimSpec}, and portability is achieved using
|
||||||
|
* {@link Dialect#trimPattern(TrimSpec, char)}.
|
||||||
|
* <p>
|
||||||
|
* For example, {@code trim(leading ' ' from text)}.
|
||||||
|
*
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
*/
|
*/
|
||||||
public class TrimFunction extends AbstractSqmSelfRenderingFunctionDescriptor {
|
public class TrimFunction extends AbstractSqmSelfRenderingFunctionDescriptor {
|
||||||
|
|
Loading…
Reference in New Issue