add some Javadoc, and rename a class

This commit is contained in:
Gavin King 2022-02-07 19:29:04 +01:00
parent c072ee9cb2
commit ccee58add8
20 changed files with 67 additions and 13 deletions

View File

@ -308,7 +308,7 @@ public abstract class AbstractHANADialect extends Dialect {
functionFactory.secondsBetween();
functionFactory.format_toVarchar();
functionFactory.currentUtcdatetimetimestamp();
functionFactory.everyAny_sumCaseCase();
functionFactory.everyAny_minMaxCase();
functionFactory.bitLength_pattern( "length(to_binary(?1))*8" );
functionFactory.listagg_stringAgg( "varchar" );

View File

@ -885,7 +885,8 @@ public abstract class Dialect implements ConversionContext {
queryEngine.getSqmFunctionRegistry().register( "extract",
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();

View File

@ -163,7 +163,7 @@ public class OracleDialect extends Dialect {
functionFactory.characterLength_length( SqlAstNodeRenderingMode.DEFAULT );
functionFactory.addMonths();
functionFactory.monthsBetween();
functionFactory.everyAny_sumCaseCase();
functionFactory.everyAny_minMaxCase();
functionFactory.median();
functionFactory.stddev();

View File

@ -218,7 +218,7 @@ public class SQLServerDialect extends AbstractTransactSQLDialect {
functionFactory.avg_castingNonDoubleArguments( this, SqlAstNodeRenderingMode.DEFAULT );
functionFactory.truncate_round();
functionFactory.everyAny_sumIif();
functionFactory.everyAny_minMaxIif();
functionFactory.bitLength_pattern( "datalength(?1) * 8" );
if ( getVersion().isSameOrAfter( 10 ) ) {

View File

@ -220,7 +220,7 @@ public class SybaseDialect extends AbstractTransactSQLDialect {
functionFactory.locate_charindex();
functionFactory.replace_strReplace();
functionFactory.everyAny_sumCaseCase();
functionFactory.everyAny_minMaxCase();
functionFactory.bitLength_pattern( "datalength(?1) * 8" );
queryEngine.getSqmFunctionRegistry().register( "timestampadd",

View File

@ -19,6 +19,8 @@ import org.hibernate.sql.ast.tree.SqlAstNode;
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
*/

View File

@ -23,6 +23,10 @@ import org.hibernate.sql.ast.tree.expression.CastTarget;
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
*/
public class CastFunction extends AbstractSqmSelfRenderingFunctionDescriptor {

View File

@ -24,6 +24,8 @@ import java.util.List;
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
*/
public class CastStrEmulation

View File

@ -812,7 +812,7 @@ public class CommonFunctionFactory {
* These are aggregate functions taking one argument,
* for SQL Server.
*/
public void everyAny_sumIif() {
public void everyAny_minMaxIif() {
functionRegistry.register( "every",
new SQLServerEveryAnyEmulation( typeConfiguration, true ) );
functionRegistry.register( "any",
@ -824,11 +824,11 @@ public class CommonFunctionFactory {
* These are aggregate functions taking one argument,
* for Oracle and Sybase.
*/
public void everyAny_sumCaseCase() {
public void everyAny_minMaxCase() {
functionRegistry.register( "every",
new CaseWhenEveryAnyEmulation( typeConfiguration, true ) );
new MinMaxCaseEveryAnyEmulation( typeConfiguration, true ) );
functionRegistry.register( "any",
new CaseWhenEveryAnyEmulation( typeConfiguration, false ) );
new MinMaxCaseEveryAnyEmulation( typeConfiguration, false ) );
}
/**

View File

@ -17,6 +17,9 @@ import org.hibernate.type.BasicType;
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
*/
public class CurrentFunction

View File

@ -23,6 +23,13 @@ import org.hibernate.type.spi.TypeConfiguration;
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
*/
public class EveryAnyEmulation extends AbstractSqmSelfRenderingFunctionDescriptor {

View File

@ -33,6 +33,10 @@ import static org.hibernate.query.sqm.produce.function.FunctionParameterType.TEM
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
*/
public class ExtractFunction

View File

@ -35,6 +35,9 @@ import static org.hibernate.query.sqm.produce.function.FunctionParameterType.INT
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
*/
public class InsertSubstringOverlayEmulation

View File

@ -22,6 +22,8 @@ import java.util.List;
import static org.hibernate.query.sqm.produce.function.FunctionParameterType.STRING;
/**
* Emulates the ANSI SQL-standard {@code position()} function using {@code locate()}.
*
* @author Gavin King
*/
public class LocatePositionEmulation extends AbstractSqmFunctionDescriptor {

View File

@ -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;
/**
* 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
*/
public class LpadRpadPadEmulation

View File

@ -22,13 +22,19 @@ import org.hibernate.type.StandardBasicTypes;
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
*/
public class CaseWhenEveryAnyEmulation extends AbstractSqmSelfRenderingFunctionDescriptor {
public class MinMaxCaseEveryAnyEmulation extends AbstractSqmSelfRenderingFunctionDescriptor {
private final boolean every;
public CaseWhenEveryAnyEmulation(TypeConfiguration typeConfiguration, boolean every) {
public MinMaxCaseEveryAnyEmulation(TypeConfiguration typeConfiguration, boolean every) {
super(
every ? "every" : "any",
FunctionKind.AGGREGATE,

View File

@ -19,6 +19,7 @@ import org.hibernate.sql.ast.tree.SqlAstNode;
import static org.hibernate.query.sqm.produce.function.FunctionParameterType.COMPARABLE;
/**
* @see CaseLeastGreatestEmulation
*
* @author Christian Beikov
*/

View File

@ -23,6 +23,12 @@ import org.hibernate.type.spi.TypeConfiguration;
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
*/
public class SQLServerEveryAnyEmulation extends AbstractSqmSelfRenderingFunctionDescriptor {

View File

@ -22,8 +22,9 @@ import org.hibernate.type.StandardBasicTypes;
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,
* otherwise renders a cast expression like {@link CastStrEmulation}.
* A special function that renders a T-SQL {@code str()} function
* if more than a single argument is given, or otherwise renders
* a {@code cast()} expression just like {@link CastStrEmulation}.
*
* @author Christian Beikov
*/

View File

@ -29,6 +29,12 @@ import static org.hibernate.query.sqm.produce.function.FunctionParameterType.TRI
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
*/
public class TrimFunction extends AbstractSqmSelfRenderingFunctionDescriptor {