HHH-14693, HHH-10668 Move non-supported dialects to the hibernate-community-dialects artifact and add the SQLite dialect originally contributed by Vlad Mihalcea which was adapted for Hibernate 6. Also add HSQLDB, MySQL and Sybase ASE configurations and a CI job config

This commit is contained in:
Christian Beikov 2021-06-23 14:56:57 +02:00
parent 16db356ba8
commit 6447ca9b26
267 changed files with 4321 additions and 1329 deletions

View File

@ -29,18 +29,24 @@ jobs:
include:
- rdbms: h2
experimental: false
- rdbms: hsqldb
experimental: false
- rdbms: derby
experimental: true
experimental: false
- rdbms: mysql
experimental: false
- rdbms: mariadb
experimental: true
experimental: false
- rdbms: postgresql
experimental: true
experimental: false
- rdbms: oracle
experimental: true
experimental: false
- rdbms: db2
experimental: true
experimental: false
- rdbms: mssql
experimental: true
experimental: false
- rdbms: sybase
experimental: false
# Running with HANA requires at least 8GB memory just for the database, which we don't have on GH Actions runners
# - rdbms: hana
# experimental: true

View File

@ -3,6 +3,10 @@
goal=
if [ "$RDBMS" == "derby" ]; then
goal="-Pdb=derby"
elif [ "$RDBMS" == "hsqldb" ]; then
goal="-Pdb=hsqldb"
elif [ "$RDBMS" == "mysql" ]; then
goal="-Pdb=mysql_ci"
elif [ "$RDBMS" == "mariadb" ]; then
goal="-Pdb=mariadb_ci"
elif [ "$RDBMS" == "postgresql" ]; then
@ -16,6 +20,8 @@ elif [ "$RDBMS" == "mssql" ]; then
goal="-Pdb=mssql_ci"
elif [ "$RDBMS" == "hana" ]; then
goal="-Pdb=hana_ci"
elif [ "$RDBMS" == "sybase" ]; then
goal="-Pdb=sybase_ci"
fi
exec ./gradlew check ${goal} -Plog-test-progress=true --stacktrace

View File

@ -18,4 +18,6 @@ elif [ "$RDBMS" == 'mssql' ]; then
bash $DIR/../docker_db.sh mssql
elif [ "$RDBMS" == 'hana' ]; then
bash $DIR/../docker_db.sh hana
elif [ "$RDBMS" == 'sybase' ]; then
bash $DIR/../docker_db.sh sybase
fi

65
dialects.adoc Normal file
View File

@ -0,0 +1,65 @@
= Dialects
A dialect is a class that provides information about the specifics of a database and translators for the SQL dialect of the database.
== Supported dialects
Hibernate supports a wide range of dialects out of the box. The following is list of officially supported databases:
* Apache Derby
* Cockroach
* Google Spanner
* H2
* HSQLDB
* IBM DB2 LUW
* IBM DB2 iSeries
* IBM DB2 z/OS
* MariaDB
* MySQL
* Oracle
* PostgreSQL
* Postgres Plus
* SAP HANA
* SQL Server
* Sybase ASE
Usually, Hibernate supports at least the database version that is also still supported by the respective vendor.
In many cases though, Hibernate supports even older versions of the databases,
but the support for these versions is not guaranteed.
Apart from the Hibernate team supported dialects, there are also community dialects.
== Community dialects
As of Hibernate 6.0, the Hibernate team decided to provide a clear way forward for community contributed dialects.
The `hibernate-core` artifact had many legacy dialects before 6.0 that were only tested and maintained on a best effort basis.
More and more database vendors requested to integrate a dialect for their database and even provided a PR with a dialect,
but the Hibernate team didn't want to add new dialects for databases that might not have a wide adoption
or any automated testing into the `hibernate-core` artifact. Even though the dialect was supposedly maintained by the vendor,
the Hibernate team was burdened with reviewing questions, issues and PRs that relate to these dialects.
To give database vendors and the community a clear way forward, the Hibernate team decided to introduce a new artifact,
called `hibernate-community-dialects` which is the new home for dialects that are maintained by vendors or individuals.
Starting with Hibernate 6.0 the `hibernate-core` artifact will only contain dialects that are supported and tested by the Hibernate team.
All the legacy dialects are moved to the `hibernate-community-dialects` artifact to have a clear separation based on the quality of the dialect.
Issues with dialects in the `hibernate-community-dialects` are usually not considered by the Hibernate team,
as the community is responsible for providing fixes and improving the dialects for newer database versions or ORM capabilities.
== Requirements for moving to hibernate-core
If a database vendor wants their database dialect to be included in the `hibernate-core` artifact,
several requirements have to be fulfilled:
* The vendor must provide access to a dedicated database server that can be used for testing
* The vendor must provide contact details to at least one employee who is mainly responsible for the maintenance of the dialect
* The responsible employee of the vendor must actively monitor and react to failures of the testsuite against the respective database
* The responsible employee of the vendor must ensure the testsuite is configured correctly in order for it to succeed on the respective database
* If the responsible employee of the vendor leaves the company, the vendor must provide contact details to a new responsible employee
In case the responsible employee is unreachable for a longer period or issues with the dialect are not attended to in a timely manner,
the Hibernate team will move the dialect back to the `hibernate-community-dialects` artifact.
Get in touch with the Hibernate team on https://hibernate.zulipchat.com/#narrow/stream/132096-hibernate-user[Zulip]
if you want to request the move of your dialect to hibernate-core.

View File

@ -2,17 +2,17 @@
mysql_5_7() {
docker rm -f mysql || true
docker run --name mysql -e MYSQL_USER=hibernate_orm_test -e MYSQL_PASSWORD=hibernate_orm_test -e MYSQL_DATABASE=hibernate_orm_test -e MYSQL_ROOT_PASSWORD=hibernate_orm_test -p3306:3306 -d mysql:5.7 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
docker run --name mysql -e MYSQL_USER=hibernate_orm_test -e MYSQL_PASSWORD=hibernate_orm_test -e MYSQL_DATABASE=hibernate_orm_test -e MYSQL_ROOT_PASSWORD=hibernate_orm_test -p3306:3306 -d mysql:5.7 --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
}
mysql_8_0() {
docker rm -f mysql || true
docker run --name mysql -e MYSQL_USER=hibernate_orm_test -e MYSQL_PASSWORD=hibernate_orm_test -e MYSQL_ROOT_PASSWORD=hibernate_orm_test -e MYSQL_DATABASE=hibernate_orm_test -e MYSQL_ROOT_PASSWORD=hibernate_orm_test -p3306:3306 -d mysql:8.0.21 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
docker run --name mysql -e MYSQL_USER=hibernate_orm_test -e MYSQL_PASSWORD=hibernate_orm_test -e MYSQL_ROOT_PASSWORD=hibernate_orm_test -e MYSQL_DATABASE=hibernate_orm_test -e MYSQL_ROOT_PASSWORD=hibernate_orm_test -p3306:3306 -d mysql:8.0.21 --character-set-server=utf8mb4 --collation-server=utf8mb4_0900_ai_ci
}
mariadb() {
docker rm -f mariadb || true
docker run --name mariadb -e MYSQL_USER=hibernate_orm_test -e MYSQL_PASSWORD=hibernate_orm_test -e MYSQL_DATABASE=hibernate_orm_test -e MYSQL_ROOT_PASSWORD=hibernate_orm_test -p3306:3306 -d mariadb:10.5.8 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
docker run --name mariadb -e MYSQL_USER=hibernate_orm_test -e MYSQL_PASSWORD=hibernate_orm_test -e MYSQL_DATABASE=hibernate_orm_test -e MYSQL_ROOT_PASSWORD=hibernate_orm_test -p3306:3306 -d mariadb:10.5.8 --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
}
postgresql_9_5() {
@ -26,8 +26,14 @@ postgresql_13() {
}
postgis(){
docker rm -f postgis || true
docker run --name postgis -e POSTGRES_USER=hibernate_orm_test -e POSTGRES_PASSWORD=hibernate_orm_test -e POSTGRES_DB=hibernate_orm_test -p5432:5432 -d postgis/postgis:11-2.5
docker rm -f postgis || true
docker run --name postgis -e POSTGRES_USER=hibernate_orm_test -e POSTGRES_PASSWORD=hibernate_orm_test -e POSTGRES_DB=hibernate_orm_test -p5432:5432 -d postgis/postgis:11-2.5
}
edb() {
#docker login containers.enterprisedb.com
docker rm -f edb || true
docker run --name edb -e ACCEPT_EULA=Yes -e DATABASE_USER=hibernate_orm_test -e DATABASE_USER_PASSWORD=hibernate_orm_test -e ENTERPRISEDB_PASSWORD=hibernate_orm_test -e DATABASE_NAME=hibernate_orm_test -e PGPORT=5433 -p 5433:5433 --mount type=tmpfs,destination=/edbvolume -d containers.enterprisedb.com/edb/edb-as-lite:v11
}
db2() {
@ -123,6 +129,126 @@ mssql() {
fi
}
sybase() {
docker rm -f sybase || true
# Yup, that sucks, but on ubuntu we need to use -T11889 as per: https://github.com/DataGrip/docker-env/issues/12
docker run -d -p 5000:5000 -p 5001:5001 --name sybase --entrypoint /bin/bash nguoianphu/docker-sybase -c "source /opt/sybase/SYBASE.sh
/opt/sybase/ASE-16_0/bin/dataserver \
-d/opt/sybase/data/master.dat \
-e/opt/sybase/ASE-16_0/install/MYSYBASE.log \
-c/opt/sybase/ASE-16_0/MYSYBASE.cfg \
-M/opt/sybase/ASE-16_0 \
-N/opt/sybase/ASE-16_0/sysam/MYSYBASE.properties \
-i/opt/sybase \
-sMYSYBASE \
-T11889
RET=\$?
exit 0
"
sybase_check() {
docker exec sybase bash -c "source /opt/sybase/SYBASE.sh;
/opt/sybase/OCS-16_0/bin/isql -Usa -P myPassword -S MYSYBASE <<EOF
Select name from sysdatabases where status2 & 48 > 0
go
quit
EOF
"
}
START_STATUS=0
j=1
while (( $j < 30 )); do
echo "Waiting for Sybase to start..."
sleep 1
j=$((j+1))
START_STATUS=$(sybase_check | grep '(0 rows affected)' | wc -c)
if (( $START_STATUS > 0 )); then
break
fi
done
if (( $j == 30 )); then
echo "Failed starting Sybase"
docker ps -a
docker logs sybase
sybase_check
exit 1
fi
export SYBASE_DB=hibernate_orm_test
export SYBASE_USER=hibernate_orm_test
export SYBASE_PASSWORD=hibernate_orm_test
docker exec sybase bash -c "source /opt/sybase/SYBASE.sh;
cat <<-EOSQL > init1.sql
use master
go
disk resize name='master', size='256m'
go
create database $SYBASE_DB on master = '96m'
go
sp_dboption $SYBASE_DB, \"single user\", true
go
alter database $SYBASE_DB log on master = '50m'
go
use $SYBASE_DB
go
exec sp_extendsegment logsegment, $SYBASE_DB, master
go
use master
go
sp_dboption $SYBASE_DB, \"single user\", false
go
use $SYBASE_DB
go
checkpoint
go
use master
go
create login $SYBASE_USER with password $SYBASE_PASSWORD
go
exec sp_dboption $SYBASE_DB, 'abort tran on log full', true
go
exec sp_dboption $SYBASE_DB, 'allow nulls by default', true
go
exec sp_dboption $SYBASE_DB, 'ddl in tran', true
go
exec sp_dboption $SYBASE_DB, 'trunc log on chkpt', true
go
exec sp_dboption $SYBASE_DB, 'full logging for select into', true
go
exec sp_dboption $SYBASE_DB, 'full logging for alter table', true
go
sp_dboption $SYBASE_DB, \"select into\", true
go
EOSQL
/opt/sybase/OCS-16_0/bin/isql -Usa -P myPassword -S MYSYBASE -i ./init1.sql
echo =============== CREATING DB ==========================
cat <<-EOSQL > init2.sql
use $SYBASE_DB
go
sp_adduser '$SYBASE_USER', '$SYBASE_USER', null
go
grant create default to $SYBASE_USER
go
grant create table to $SYBASE_USER
go
grant create view to $SYBASE_USER
go
grant create rule to $SYBASE_USER
go
grant create function to $SYBASE_USER
go
grant create procedure to $SYBASE_USER
go
commit
go
EOSQL
/opt/sybase/OCS-16_0/bin/isql -Usa -P myPassword -S MYSYBASE -i ./init2.sql"
echo "Sybase successfully started"
}
oracle() {
docker rm -f oracle || true
# We need to use the defaults
@ -158,6 +284,7 @@ EOF\""
}
oracle_ee() {
#docker login
docker rm -f oracle || true
# We need to use the defaults
# sys as sysdba/Oradoc_db1
@ -244,18 +371,21 @@ EOF
if [ -z ${1} ]; then
echo "No db name provided"
echo "Provide one of:"
echo -e "\tcockroachdb"
echo -e "\tdb2"
echo -e "\tdb2_spatial"
echo -e "\tedb"
echo -e "\thana"
echo -e "\tmariadb"
echo -e "\tmssql"
echo -e "\tmysql_5_7"
echo -e "\tmysql_8_0"
echo -e "\tmariadb"
echo -e "\tpostgresql_9_5"
echo -e "\tpostgresql_13"
echo -e "\tdb2"
echo -e "\tmssql"
echo -e "\toracle"
echo -e "\toracle_ee"
echo -e "\tpostgis"
echo -e "\tdb2_spatial"
echo -e "\thana"
echo -e "\tcockroachdb"
echo -e "\tpostgresql_13"
echo -e "\tpostgresql_9_5"
echo -e "\tsybase"
else
${1}
fi

View File

@ -59,14 +59,6 @@ dependencies {
testImplementation libraries.mockito_inline
testRuntimeOnly libraries.wildfly_transaction_client
testRuntimeOnly libraries.h2
testRuntimeOnly libraries.hsqldb
testRuntimeOnly libraries.postgresql
testRuntimeOnly libraries.mysql
testRuntimeOnly libraries.mariadb
testRuntimeOnly libraries.mssql
testRuntimeOnly libraries.hana
testRuntimeOnly libraries.cockroachdb
testRuntimeOnly libraries.ehcache3
}

View File

@ -7,6 +7,7 @@
package org.hibernate.userguide.mapping.basic;
import java.util.BitSet;
import javax.persistence.Column;
import javax.persistence.ColumnResult;
import javax.persistence.ConstructorResult;
import javax.persistence.Entity;
@ -94,7 +95,7 @@ public class BitSetUserTypeTest extends BaseCoreFunctionalTestCase {
query =
"SELECT " +
" pr.id AS \"pr.id\", " +
" pr.bitset AS \"pr.bitset\" " +
" pr.bitset_col AS \"pr.bitset\" " +
"FROM Product pr " +
"WHERE pr.id = :id",
resultSetMapping = "Person"
@ -117,6 +118,7 @@ public class BitSetUserTypeTest extends BaseCoreFunctionalTestCase {
private Integer id;
@Type( type = "bitset" )
@Column(name = "bitset_col")
private BitSet bitSet;
//Constructors, getters, and setters are omitted for brevity

View File

@ -14,8 +14,10 @@ import javax.persistence.Id;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.dialect.SybaseDialect;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.SkipForDialect;
import org.junit.Test;
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
@ -33,6 +35,7 @@ public class DateWithTemporalTimeTest extends BaseEntityManagerFunctionalTestCas
}
@Test
@SkipForDialect(value = SybaseDialect.class, comment = "The jTDS driver doesn't allow setting a timestamp through setTime")
public void testLifecycle() {
doInJPA( this::entityManagerFactory, entityManager -> {
DateEvent dateEvent = new DateEvent( new Date() );

View File

@ -10,11 +10,8 @@ import javax.persistence.Entity;
import javax.persistence.Id;
import org.hibernate.annotations.Nationalized;
import org.hibernate.dialect.DerbyDialect;
import org.hibernate.dialect.PostgreSQL81Dialect;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.SkipForDialect;
import org.junit.Test;
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
@ -23,13 +20,6 @@ import static org.junit.Assert.assertEquals;
/**
* @author Vlad Mihalcea
*/
@SkipForDialect(
value = {
PostgreSQL81Dialect.class,
DerbyDialect.class
},
comment = "@see https://hibernate.atlassian.net/browse/HHH-10693 and Derby doesn't support nationalized type"
)
public class NationalizedTest extends BaseEntityManagerFunctionalTestCase {
@Override

View File

@ -16,6 +16,7 @@ import javax.persistence.Table;
import org.hibernate.annotations.Subselect;
import org.hibernate.annotations.Synchronize;
import org.hibernate.dialect.DerbyDialect;
import org.hibernate.dialect.SybaseASEDialect;
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
import org.hibernate.testing.orm.junit.Jpa;
@ -37,6 +38,7 @@ import static org.junit.Assert.assertEquals;
}
)
@SkipForDialect( dialectClass = DerbyDialect.class, reason = "Derby doesn't support a CONCAT function" )
@SkipForDialect( dialectClass = SybaseASEDialect.class, reason = "Sybase doesn't support a CONCAT function" )
public class SubselectTest {
@Test

View File

@ -97,7 +97,7 @@ hibernate.connection.url jdbc:hsqldb:./build/db/hsqldb/hibernate
## TimesTen
#hibernate.dialect org.hibernate.dialect.TimesTenDialect
#hibernate.dialect org.hibernate.community.dialect.TimesTenDialect
#hibernate.connection.driver_class com.timesten.jdbc.TimesTenDriver
#hibernate.connection.url jdbc:timesten:direct:test
#hibernate.connection.username
@ -138,7 +138,7 @@ hibernate.connection.url jdbc:hsqldb:./build/db/hsqldb/hibernate
## SAP MaxDB
#hibernate.dialect org.hibernate.dialect.MaxDBDialect
#hibernate.dialect org.hibernate.community.dialect.MaxDBDialect
#hibernate.connection.driver_class com.sap.dbtech.jdbc.DriverSapDB
#hibernate.connection.url jdbc:sapdb://localhost/TST
#hibernate.connection.username TEST
@ -181,7 +181,7 @@ hibernate.connection.url jdbc:hsqldb:./build/db/hsqldb/hibernate
## older versions (before Ingress 2006)
#hibernate.dialect org.hibernate.dialect.IngresDialect
#hibernate.dialect org.hibernate.community.dialect.IngresDialect
#hibernate.connection.driver_class ca.edbc.jdbc.EdbcDriver
#hibernate.connection.url jdbc:edbc://localhost:II7/database
#hibernate.connection.username user
@ -189,7 +189,7 @@ hibernate.connection.url jdbc:hsqldb:./build/db/hsqldb/hibernate
## Ingres 2006 or later
#hibernate.dialect org.hibernate.dialect.IngresDialect
#hibernate.dialect org.hibernate.community.dialect.IngresDialect
#hibernate.connection.driver_class com.ingres.jdbc.IngresDriver
#hibernate.connection.url jdbc:ingres://localhost:II7/database;CURSOR=READONLY;auto=multi
#hibernate.connection.username user
@ -197,7 +197,7 @@ hibernate.connection.url jdbc:hsqldb:./build/db/hsqldb/hibernate
## Mimer SQL
#hibernate.dialect org.hibernate.dialect.MimerSQLDialect
#hibernate.dialect org.hibernate.community.dialect.MimerSQLDialect
#hibernate.connection.driver_class com.mimer.jdbc.Driver
#hibernate.connection.url jdbc:mimer:multi1
#hibernate.connection.username hibernate
@ -206,7 +206,7 @@ hibernate.connection.url jdbc:hsqldb:./build/db/hsqldb/hibernate
## InterSystems Cache
#hibernate.dialect org.hibernate.dialect.Cache71Dialect
#hibernate.dialect org.hibernate.community.dialect.Cache71Dialect
#hibernate.connection.driver_class com.intersys.jdbc.CacheDriver
#hibernate.connection.username _SYSTEM
#hibernate.connection.password SYS

View File

@ -80,7 +80,7 @@ hibernate.connection.url @DB_URL@
## TimesTen (not supported yet)
#hibernate.dialect org.hibernate.dialect.TimesTenDialect
#hibernate.dialect org.hibernate.community.dialect.TimesTenDialect
#hibernate.connection.driver_class com.timesten.jdbc.TimesTenDriver
#hibernate.connection.url jdbc:timesten:direct:test
#hibernate.connection.username
@ -121,7 +121,7 @@ hibernate.connection.url @DB_URL@
## SAP MaxDB
#hibernate.dialect org.hibernate.dialect.MaxDBDialect
#hibernate.dialect org.hibernate.community.dialect.MaxDBDialect
#hibernate.connection.driver_class com.sap.dbtech.jdbc.DriverSapDB
#hibernate.connection.url jdbc:sapdb://localhost/TST
#hibernate.connection.username TEST
@ -158,7 +158,7 @@ hibernate.connection.url @DB_URL@
## Ingres
#hibernate.dialect org.hibernate.dialect.IngresDialect
#hibernate.dialect org.hibernate.community.dialect.IngresDialect
#hibernate.connection.driver_class ca.edbc.jdbc.EdbcDriver
#hibernate.connection.url jdbc:edbc://localhost:II7/database
#hibernate.connection.username user
@ -167,7 +167,7 @@ hibernate.connection.url @DB_URL@
## Mimer SQL
#hibernate.dialect org.hibernate.dialect.MimerSQLDialect
#hibernate.dialect org.hibernate.community.dialect.MimerSQLDialect
#hibernate.connection.driver_class com.mimer.jdbc.Driver
#hibernate.connection.url jdbc:mimer:multi1
#hibernate.connection.username hibernate

View File

@ -57,16 +57,39 @@ ext {
// Disable prepared statement caching due to https://www.postgresql.org/message-id/CAEcMXhmmRd4-%2BNQbnjDT26XNdUoXdmntV9zdr8%3DTu8PL9aVCYg%40mail.gmail.com
'jdbc.url' : 'jdbc:postgresql://' + dbHost + '/hibernate_orm_test?preparedStatementCacheQueries=0'
],
edb_ci : [
'db.dialect' : 'org.hibernate.dialect.PostgresPlusDialect',
'jdbc.driver': 'org.postgresql.Driver',
'jdbc.user' : 'hibernate_orm_test',
'jdbc.pass' : 'hibernate_orm_test',
// Disable prepared statement caching due to https://www.postgresql.org/message-id/CAEcMXhmmRd4-%2BNQbnjDT26XNdUoXdmntV9zdr8%3DTu8PL9aVCYg%40mail.gmail.com
'jdbc.url' : 'jdbc:postgresql://' + dbHost + '/hibernate_orm_test?preparedStatementCacheQueries=0'
],
sybase_ci : [
'db.dialect' : 'org.hibernate.dialect.SybaseASEDialect',
'jdbc.driver': 'net.sourceforge.jtds.jdbc.Driver',
'jdbc.user' : 'hibernate_orm_test',
'jdbc.pass' : 'hibernate_orm_test',
// Disable prepared statement caching to avoid issues with changing schemas
'jdbc.url' : 'jdbc:jtds:sybase://' + dbHost + ':5000/hibernate_orm_test;maxStatements=0;cacheMetaData=false'
],
mysql : [
'db.dialect' : 'org.hibernate.dialect.MySQLDialect',
'jdbc.driver': 'com.mysql.jdbc.Driver',
'jdbc.driver': 'com.mysql.cj.jdbc.Driver',
'jdbc.user' : 'hibernateormtest',
'jdbc.pass' : 'hibernateormtest',
'jdbc.url' : 'jdbc:mysql://' + dbHost + '/hibernate_orm_test'
],
mysql_docker : [
'db.dialect' : 'org.hibernate.dialect.MySQLDialect',
'jdbc.driver': 'com.mysql.jdbc.Driver',
'jdbc.driver': 'com.mysql.cj.jdbc.Driver',
'jdbc.user' : 'hibernate_orm_test',
'jdbc.pass' : 'hibernate_orm_test',
'jdbc.url' : 'jdbc:mysql://' + dbHost + '/hibernate_orm_test?useSSL=false'
],
mysql_ci : [
'db.dialect' : 'org.hibernate.dialect.MySQLDialect',
'jdbc.driver': 'com.mysql.cj.jdbc.Driver',
'jdbc.user' : 'hibernate_orm_test',
'jdbc.pass' : 'hibernate_orm_test',
'jdbc.url' : 'jdbc:mysql://' + dbHost + '/hibernate_orm_test?useSSL=false'
@ -77,7 +100,7 @@ ext {
'jdbc.driver': 'com.mysql.cj.jdbc.Driver',
'jdbc.user' : 'hibernate_orm_test',
'jdbc.pass' : 'hibernate_orm_test',
'jdbc.url' : 'jdbc:mysql://' + dbHost + '/hibernate_orm_test?allowPublicKeyRetrieval=true&useSSL=false'
'jdbc.url' : 'jdbc:mysql://' + dbHost + '/hibernate_orm_test?useSSL=false'
],
mariadb : [
'db.dialect' : 'org.hibernate.dialect.MariaDBDialect',

View File

@ -89,9 +89,9 @@ dependencies {
testRuntimeOnly libraries.mariadb
testRuntimeOnly libraries.mssql
testRuntimeOnly libraries.informix
testRuntimeOnly libraries.hana
testRuntimeOnly libraries.cockroachdb
testRuntimeOnly libraries.oracle
testRuntimeOnly libraries.sybase
// Since both the DB2 driver and HANA have a package "net.jpountz" we have to add dependencies conditionally
// This is due to the "no split-packages" requirement of Java 9+

View File

@ -139,7 +139,7 @@ ext {
byteman_install: "org.jboss.byteman:byteman-install:${bytemanVersion}",
byteman_bmunit: "org.jboss.byteman:byteman-bmunit:${bytemanVersion}",
h2: "com.h2database:h2:${h2Version}",
hsqldb: "org.hsqldb:hsqldb:2.3.2",
hsqldb: "org.hsqldb:hsqldb:2.3.6",
derby: "org.apache.derby:derby:10.11.1.1",
postgresql: 'org.postgresql:postgresql:42.2.16',
mysql: 'mysql:mysql-connector-java:8.0.17',
@ -150,6 +150,7 @@ ext {
mssql: 'com.microsoft.sqlserver:mssql-jdbc:7.2.1.jre8',
db2: 'com.ibm.db2:jcc:11.5.4.0',
hana: 'com.sap.cloud.db.jdbc:ngdbc:2.4.59',
sybase: 'net.sourceforge.jtds:jtds:1.3.1',
jodaTime: "joda-time:joda-time:${jodaTimeVersion}",

View File

@ -0,0 +1,31 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
description = 'Hibernate\'s community supported dialects'
apply from: rootProject.file( 'gradle/published-java-module.gradle' )
dependencies {
api( project( ':hibernate-core' ) ) {
// Exclude access to this to avoid future use.
// todo (6.0) : this should no longer be transitive from core. Come back and verify this
exclude group: "org.javassist", module: "javassist"
}
implementation libraries.commons_annotations
// TODO HHH-13703: get rid of this dependency
implementation libraries.dom4j
testImplementation project( ':hibernate-testing' )
testImplementation project( path: ':hibernate-core', configuration: 'tests' )
}
//test {
// dependsOn project(':hibernate-core').tasks.compileTestJava
// test.testClassesDirs = project(':hibernate-core').tasks.test.testClassesDirs
//}

View File

@ -4,16 +4,18 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
import org.hibernate.HibernateException;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.OracleDialect;
import org.hibernate.dialect.function.CommonFunctionFactory;
import org.hibernate.dialect.identity.CUBRIDIdentityColumnSupport;
import org.hibernate.community.dialect.identity.CUBRIDIdentityColumnSupport;
import org.hibernate.dialect.identity.IdentityColumnSupport;
import org.hibernate.dialect.pagination.LimitHandler;
import org.hibernate.dialect.pagination.LimitLimitHandler;
import org.hibernate.dialect.sequence.CUBRIDSequenceSupport;
import org.hibernate.community.dialect.sequence.CUBRIDSequenceSupport;
import org.hibernate.dialect.sequence.SequenceSupport;
import org.hibernate.engine.jdbc.Size;
import org.hibernate.engine.spi.SessionFactoryImplementor;
@ -25,7 +27,7 @@ import org.hibernate.sql.ast.SqlAstTranslatorFactory;
import org.hibernate.sql.ast.spi.StandardSqlAstTranslatorFactory;
import org.hibernate.sql.ast.tree.Statement;
import org.hibernate.sql.exec.spi.JdbcOperation;
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorCUBRIDDatabaseImpl;
import org.hibernate.community.dialect.sequence.SequenceInformationExtractorCUBRIDDatabaseImpl;
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeDescriptorRegistry;
@ -288,6 +290,16 @@ public class CUBRIDDialect extends Dialect {
return false;
}
@Override
public boolean supportsOffsetInSubquery() {
return true;
}
@Override
public boolean supportsTemporaryTables() {
return false;
}
@Override
public SqlAstTranslatorFactory getSqlAstTranslatorFactory() {
return new StandardSqlAstTranslatorFactory() {

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
import java.util.List;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
/**
* Cach&eacute; 2007.1 dialect.
@ -69,7 +69,7 @@ package org.hibernate.dialect;
* </tr>
* <tr>
* <td>hibernate.dialect</td>
* <td>org.hibernate.dialect.Cache71Dialect</td>
* <td>org.hibernate.community.dialect.Cache71Dialect</td>
* </tr>
* <tr>
* <td>hibernate.connection.driver_class</td>
@ -104,7 +104,7 @@ package org.hibernate.dialect;
* <br>
* <p/>
* <ol>
* <li>org.hibernate.dialect.Cache71Dialect (requires Cach&eacute;
* <li>org.hibernate.community.dialect.Cache71Dialect (requires Cach&eacute;
* 2007.1 or above)</li>
* <p/>
* </ol>

View File

@ -4,17 +4,19 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
import org.hibernate.LockMode;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.OracleDialect;
import org.hibernate.dialect.function.CommonFunctionFactory;
import org.hibernate.dialect.identity.CacheIdentityColumnSupport;
import org.hibernate.community.dialect.identity.CacheIdentityColumnSupport;
import org.hibernate.dialect.identity.IdentityColumnSupport;
import org.hibernate.dialect.lock.*;
import org.hibernate.dialect.pagination.LimitHandler;
import org.hibernate.dialect.pagination.TopLimitHandler;
import org.hibernate.dialect.sequence.CacheSequenceSupport;
import org.hibernate.community.dialect.sequence.CacheSequenceSupport;
import org.hibernate.dialect.sequence.SequenceSupport;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.exception.ConstraintViolationException;
@ -26,7 +28,6 @@ import org.hibernate.internal.util.JdbcExceptionHelper;
import org.hibernate.persister.entity.Lockable;
import org.hibernate.query.TemporalUnit;
import org.hibernate.query.spi.QueryEngine;
import org.hibernate.sql.CacheJoinFragment;
import org.hibernate.sql.JoinFragment;
import org.hibernate.sql.ast.SqlAstTranslator;
import org.hibernate.sql.ast.SqlAstTranslatorFactory;
@ -400,6 +401,12 @@ public class CacheDialect extends Dialect {
return true;
}
@Override
public boolean supportsOrderByInSubquery() {
// This is just a guess
return false;
}
@Override
public boolean supportsResultSetPositionQueryMethodsOnForwardOnlyCursor() {
return false;

View File

@ -1,26 +1,28 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.sql;
import org.hibernate.AssertionFailure;
/**
* A Cach&eacute; dialect join. Differs from ANSI only in that full outer join
* is not supported.
*
* @author Jeff Miller
* @author Jonathan Levinson
*/
public class CacheJoinFragment extends ANSIJoinFragment {
public void addJoin(String rhsTableName, String rhsAlias, String[] lhsColumns, String[] rhsColumns, JoinType joinType, String on) {
if ( joinType == JoinType.FULL_JOIN ) {
throw new AssertionFailure( "Cache does not support full outer joins" );
}
super.addJoin( rhsTableName, rhsAlias, lhsColumns, rhsColumns, joinType, on );
}
}
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.community.dialect;
import org.hibernate.AssertionFailure;
import org.hibernate.sql.ANSIJoinFragment;
import org.hibernate.sql.JoinType;
/**
* A Cach&eacute; dialect join. Differs from ANSI only in that full outer join
* is not supported.
*
* @author Jeff Miller
* @author Jonathan Levinson
*/
public class CacheJoinFragment extends ANSIJoinFragment {
public void addJoin(String rhsTableName, String rhsAlias, String[] lhsColumns, String[] rhsColumns, JoinType joinType, String on) {
if ( joinType == JoinType.FULL_JOIN ) {
throw new AssertionFailure( "Cache does not support full outer joins" );
}
super.addJoin( rhsTableName, rhsAlias, lhsColumns, rhsColumns, joinType, on );
}
}

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
import java.util.List;
@ -54,14 +54,14 @@ public class CacheSqlAstTranslator<T extends JdbcOperation> extends AbstractSqlA
@Override
protected void visitSqlSelections(SelectClause selectClause) {
renderTopClause( (QuerySpec) getQueryPartStack().getCurrent(), true );
renderTopClause( (QuerySpec) getQueryPartStack().getCurrent(), true, true );
super.visitSqlSelections( selectClause );
}
@Override
protected void renderTopClause(QuerySpec querySpec, boolean addOffset) {
protected void renderTopClause(QuerySpec querySpec, boolean addOffset, boolean needsParenthesis) {
assertRowsOnlyFetchClauseType( querySpec );
super.renderTopClause( querySpec, addOffset );
super.renderTopClause( querySpec, addOffset, needsParenthesis );
}
@Override

View File

@ -0,0 +1,238 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.community.dialect;
import org.hibernate.dialect.Database;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
/**
* A list of community maintained relational database systems for which Hibernate can resolve a {@link Dialect}.
*
* However, Hibernate can work with other database systems that are not listed by the {@link Database}
* enumeration, as long as a {@link Dialect} implementation class is provided via the {@code hibernate.dialect}
* configuration property.
*
* @author Christian Beikov
*/
public enum CommunityDatabase {
SQLITE {
@Override
public Dialect createDialect(DialectResolutionInfo info) {
return new SQLiteDialect( info );
}
@Override
public boolean productNameMatches(String databaseName) {
return databaseName.startsWith( "SQLite" );
}
},
INGRES {
@Override
public Dialect createDialect(DialectResolutionInfo info) {
return new IngresDialect( info );
}
@Override
public boolean productNameMatches(String databaseName) {
return databaseName.toLowerCase().startsWith( "ingres" );
}
@Override
public String getDriverClassName(String jdbcUrl) {
return "com.ingres.jdbc.IngresDriver";
}
},
INFORMIX {
@Override
public Dialect createDialect(DialectResolutionInfo info) {
return new InformixDialect( info );
}
@Override
public boolean productNameMatches(String databaseName) {
//usually "Informix Dynamic Server"
return databaseName.toLowerCase().startsWith( "informix" );
}
@Override
public String getDriverClassName(String jdbcUrl) {
return "com.informix.jdbc.IfxDriver" ;
}
@Override
public String getUrlPrefix() {
return "jdbc:informix-";
}
},
FIREBIRD {
@Override
public Dialect createDialect(DialectResolutionInfo info) {
return new FirebirdDialect( info );
}
@Override
public boolean productNameMatches(String databaseName) {
return databaseName.startsWith( "Firebird" );
}
@Override
public String getDriverClassName(String jdbcUrl) {
return "org.firebirdsql.jdbc.FBDriver";
}
@Override
public String getUrlPrefix() {
return "jdbc:firebirdsql:";
}
},
CACHE {
@Override
public Dialect createDialect(DialectResolutionInfo info) {
return new CacheDialect();
}
@Override
public boolean productNameMatches(String databaseName) {
return databaseName.startsWith( "Cache" );
}
},
CUBRID {
@Override
public Dialect createDialect(DialectResolutionInfo info) {
return new CUBRIDDialect();
}
@Override
public boolean productNameMatches(String databaseName) {
return "CUBRID".equalsIgnoreCase( databaseName );
}
@Override
public String getDriverClassName(String jdbcUrl) {
return "cubrid.jdbc.driver.CUBRIDDriver";
}
},
MIMER {
@Override
public Dialect createDialect(DialectResolutionInfo info) {
return new MimerSQLDialect();
}
@Override
public boolean productNameMatches(String databaseName) {
return databaseName.startsWith( "Mimer SQL" );
}
@Override
public String getDriverClassName(String jdbcUrl) {
return "com.mimer.jdbc.Driver";
}
},
MAXDB {
@Override
public Dialect createDialect(DialectResolutionInfo info) {
return new MaxDBDialect();
}
@Override
public boolean productNameMatches(String databaseName) {
return databaseName.toLowerCase().startsWith( "sap db" )
|| databaseName.toLowerCase().startsWith( "maxdb" );
}
@Override
public String getDriverClassName(String jdbcUrl) {
return "com.sap.dbtech.jdbc.DriverSapDB";
}
@Override
public String getUrlPrefix() {
return "jdbc:sapdb:";
}
},
SYBASE_ANYWHERE {
@Override
public Dialect createDialect(DialectResolutionInfo info) {
final String databaseName = info.getDatabaseName();
if ( isASA( databaseName ) ) {
return new SybaseAnywhereDialect( info );
}
return null;
}
private boolean isASA(String databaseName) {
return databaseName.startsWith( "Adaptive Server Anywhere" )
|| "SQL Anywhere".equals( databaseName );
}
@Override
public boolean productNameMatches(String productName) {
return isASA( productName );
}
@Override
public boolean matchesUrl(String jdbcUrl) {
return jdbcUrl.startsWith( "jdbc:sybase:" )
|| jdbcUrl.startsWith( "jdbc:sqlanywhere:" );
}
},
TERADATA {
@Override
public Dialect createDialect(DialectResolutionInfo info) {
return new TeradataDialect( info );
}
@Override
public boolean productNameMatches(String databaseName) {
return "Teradata".equals( databaseName );
}
@Override
public String getDriverClassName(String jdbcUrl) {
return "com.teradata.jdbc.TeraDriver";
}
},
TIMESTEN {
@Override
public Dialect createDialect(DialectResolutionInfo info) {
return new TimesTenDialect();
}
@Override
public boolean productNameMatches(String databaseName) {
return databaseName.toLowerCase().startsWith( "timesten" );
}
};
/**
* Does this database match the given metadata?
*/
public boolean matchesResolutionInfo(DialectResolutionInfo info) {
return productNameMatches( info.getDatabaseName() );
}
/**
* Does this database have the given product name?
*/
public abstract boolean productNameMatches(String productName);
/**
* Create a {@link Dialect} for the given metadata.
*/
public abstract Dialect createDialect(DialectResolutionInfo info);
/**
* Get the name of the JDBC driver class for this database,
* or null if we're not too sure what it should be.
*/
public String getDriverClassName(String jdbcUrl) {
return null;
}
/**
* Get the JDBC URL prefix used by this database.
*/
public String getUrlPrefix() {
return "jdbc:" + toString().toLowerCase() + ":";
}
/**
* Does the given JDBC URL connect to this database?
*/
public boolean matchesUrl(String jdbcUrl) {
return jdbcUrl.toLowerCase().startsWith( getUrlPrefix() );
}
}

View File

@ -0,0 +1,31 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.community.dialect;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolver;
/**
* The DialectResolver implementation for community maintained dialects
*
* @author Christian Beikov
*/
public class CommunityDialectResolver implements DialectResolver {
@Override
public Dialect resolveDialect(DialectResolutionInfo info) {
for ( CommunityDatabase database : CommunityDatabase.values() ) {
if ( database.matchesResolutionInfo( info ) ) {
return database.createDialect( info );
}
}
return null;
}
}

View File

@ -0,0 +1,61 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.community.dialect;
import java.util.Objects;
import org.hibernate.boot.registry.selector.spi.DialectSelector;
import org.hibernate.dialect.Dialect;
public class CommunityDialectSelector implements DialectSelector {
@Override
public Class<? extends Dialect> resolve(String name) {
Objects.requireNonNull( name );
if ( name.isEmpty() ) {
return null;
}
switch ( name ) {
case "Cache":
return CacheDialect.class;
case "Cache71":
return Cache71Dialect.class;
case "CUBRID":
return CUBRIDDialect.class;
case "Firebird":
return FirebirdDialect.class;
case "Informix":
return InformixDialect.class;
case "Informix10":
return Informix10Dialect.class;
case "Ingres":
return IngresDialect.class;
case "Ingres9":
return Ingres9Dialect.class;
case "Ingres10":
return Ingres10Dialect.class;
case "MimerSQL":
return MimerSQLDialect.class;
case "RDMSOS2200":
return RDMSOS2200Dialect.class;
case "SAPDB":
return SAPDBDialect.class;
case "MaxDB":
return MaxDBDialect.class;
case "SybaseAnywhere":
return SybaseAnywhereDialect.class;
case "Teradata":
return TeradataDialect.class;
case "Teradata14":
return Teradata14Dialect.class;
case "TimesTen":
return TimesTenDialect.class;
}
return null;
}
}

View File

@ -4,20 +4,22 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
import org.hibernate.HibernateException;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.dialect.BooleanDecoder;
import org.hibernate.dialect.Dialect;
import org.hibernate.query.NullOrdering;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.function.CommonFunctionFactory;
import org.hibernate.dialect.identity.FirebirdIdentityColumnSupport;
import org.hibernate.community.dialect.identity.FirebirdIdentityColumnSupport;
import org.hibernate.dialect.identity.IdentityColumnSupport;
import org.hibernate.dialect.pagination.LimitHandler;
import org.hibernate.dialect.pagination.OffsetFetchLimitHandler;
import org.hibernate.dialect.pagination.SkipFirstLimitHandler;
import org.hibernate.dialect.sequence.FirebirdSequenceSupport;
import org.hibernate.dialect.sequence.InterbaseSequenceSupport;
import org.hibernate.community.dialect.pagination.SkipFirstLimitHandler;
import org.hibernate.community.dialect.sequence.FirebirdSequenceSupport;
import org.hibernate.community.dialect.sequence.InterbaseSequenceSupport;
import org.hibernate.dialect.sequence.SequenceSupport;
import org.hibernate.engine.jdbc.Size;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
@ -46,7 +48,7 @@ import org.hibernate.sql.ast.SqlAstTranslatorFactory;
import org.hibernate.sql.ast.spi.StandardSqlAstTranslatorFactory;
import org.hibernate.sql.ast.tree.Statement;
import org.hibernate.sql.exec.spi.JdbcOperation;
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorFirebirdDatabaseImpl;
import org.hibernate.community.dialect.sequence.SequenceInformationExtractorFirebirdDatabaseImpl;
import org.hibernate.tool.schema.extract.internal.SequenceNameExtractorImpl;
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
import org.hibernate.type.StandardBasicTypes;
@ -317,6 +319,11 @@ public class FirebirdDialect extends Dialect {
};
}
@Override
public boolean supportsTruncateWithCast(){
return false;
}
/**
* Firebird 2.5 doesn't have a real {@link java.sql.Types#BOOLEAN}
* type, so...
@ -665,6 +672,21 @@ public class FirebirdDialect extends Dialect {
return getVersion() >= 150;
}
@Override
public boolean supportsOffsetInSubquery() {
return true;
}
@Override
public boolean supportsValuesListForInsert() {
return false;
}
@Override
public boolean supportsWindowFunctions() {
return getVersion() >= 300;
}
@Override
public String translateExtractField(TemporalUnit unit) {
switch ( unit ) {

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,21 +1,21 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect;
/**
* Dialect for Informix 10
*
* @deprecated use {@code InformixDialect(10)}
*/
@Deprecated
public class Informix10Dialect extends InformixDialect {
public Informix10Dialect() {
super(10);
}
}
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.community.dialect;
/**
* Dialect for Informix 10
*
* @deprecated use {@code InformixDialect(10)}
*/
@Deprecated
public class Informix10Dialect extends InformixDialect {
public Informix10Dialect() {
super(10);
}
}

View File

@ -4,21 +4,25 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
import org.hibernate.boot.TempTableDdlTransactionHandling;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.GroupByConstantRenderingStrategy;
import org.hibernate.dialect.Replacer;
import org.hibernate.dialect.function.CommonFunctionFactory;
import org.hibernate.dialect.function.CaseLeastGreatestEmulation;
import org.hibernate.dialect.identity.IdentityColumnSupport;
import org.hibernate.dialect.identity.InformixIdentityColumnSupport;
import org.hibernate.dialect.pagination.FirstLimitHandler;
import org.hibernate.community.dialect.identity.InformixIdentityColumnSupport;
import org.hibernate.community.dialect.pagination.FirstLimitHandler;
import org.hibernate.dialect.pagination.LimitHandler;
import org.hibernate.dialect.pagination.SkipFirstLimitHandler;
import org.hibernate.dialect.sequence.InformixSequenceSupport;
import org.hibernate.community.dialect.pagination.SkipFirstLimitHandler;
import org.hibernate.community.dialect.sequence.InformixSequenceSupport;
import org.hibernate.dialect.sequence.SequenceSupport;
import org.hibernate.dialect.unique.InformixUniqueDelegate;
import org.hibernate.community.dialect.unique.InformixUniqueDelegate;
import org.hibernate.dialect.unique.UniqueDelegate;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
import org.hibernate.engine.spi.LoadQueryInfluencers;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor;
import org.hibernate.exception.spi.ViolatedConstraintNameExtractor;
@ -27,17 +31,26 @@ import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
import org.hibernate.query.TemporalUnit;
import org.hibernate.query.spi.QueryEngine;
import org.hibernate.query.spi.QueryOptions;
import org.hibernate.query.spi.QueryParameterBindings;
import org.hibernate.query.sqm.internal.DomainParameterXref;
import org.hibernate.query.sqm.mutation.internal.idtable.AfterUseAction;
import org.hibernate.query.sqm.mutation.internal.idtable.IdTable;
import org.hibernate.query.sqm.mutation.internal.idtable.LocalTemporaryTableStrategy;
import org.hibernate.query.sqm.mutation.internal.idtable.TempIdTableExporter;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
import org.hibernate.query.sqm.sql.SqmTranslator;
import org.hibernate.query.sqm.sql.SqmTranslatorFactory;
import org.hibernate.query.sqm.sql.StandardSqmTranslatorFactory;
import org.hibernate.query.sqm.tree.select.SqmSelectStatement;
import org.hibernate.sql.ast.SqlAstTranslator;
import org.hibernate.sql.ast.SqlAstTranslatorFactory;
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
import org.hibernate.sql.ast.spi.StandardSqlAstTranslatorFactory;
import org.hibernate.sql.ast.tree.Statement;
import org.hibernate.sql.ast.tree.select.SelectStatement;
import org.hibernate.sql.exec.spi.JdbcOperation;
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorInformixDatabaseImpl;
import org.hibernate.community.dialect.sequence.SequenceInformationExtractorInformixDatabaseImpl;
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
import org.hibernate.type.StandardBasicTypes;
@ -165,6 +178,29 @@ public class InformixDialect extends Dialect {
queryEngine.getSqmFunctionRegistry().register( "greatest", new CaseLeastGreatestEmulation( false ) );
}
@Override
public SqmTranslatorFactory getSqmTranslatorFactory() {
return new StandardSqmTranslatorFactory() {
@Override
public SqmTranslator<SelectStatement> createSelectTranslator(
SqmSelectStatement<?> sqmSelectStatement,
QueryOptions queryOptions,
DomainParameterXref domainParameterXref,
QueryParameterBindings domainParameterBindings,
LoadQueryInfluencers loadQueryInfluencers,
SqlAstCreationContext creationContext) {
return new InformixSqmToSqlAstConverter<>(
sqmSelectStatement,
queryOptions,
domainParameterXref,
domainParameterBindings,
loadQueryInfluencers,
creationContext
);
}
};
}
@Override
public SqlAstTranslatorFactory getSqlAstTranslatorFactory() {
return new StandardSqlAstTranslatorFactory() {
@ -294,6 +330,12 @@ public class InformixDialect extends Dialect {
return false;
}
@Override
public boolean supportsOrderByInSubquery() {
// This is just a guess
return false;
}
@Override
public ViolatedConstraintNameExtractor getViolatedConstraintNameExtractor() {
return EXTRACTOR;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
import java.util.List;
@ -114,11 +114,8 @@ public class InformixSqlAstTranslator<T extends JdbcOperation> extends AbstractS
// We render an empty group instead of literals as some DBs don't support grouping by literals
// Note that integer literals, which refer to select item positions, are handled in #visitGroupByClause
if ( expression instanceof Literal ) {
// todo (6.0): We need to introduce a dummy from clause item
// String fromItem = ", (select 1 x " + dialect.getFromDual() + ") dummy";
// sqlBuffer.insert( fromEndIndex, fromItem );
// appendSql( "dummy.x" );
throw new UnsupportedOperationException( "Column reference strategy is not yet implemented!" );
// Note that this depends on the SqmToSqlAstConverter to add a dummy table group
appendSql( "dummy_.x" );
}
else if ( expression instanceof Summarization ) {
// This could theoretically be emulated by rendering all grouping variations of the query and

View File

@ -0,0 +1,83 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.community.dialect;
import org.hibernate.engine.spi.LoadQueryInfluencers;
import org.hibernate.query.spi.QueryOptions;
import org.hibernate.query.spi.QueryParameterBindings;
import org.hibernate.query.sqm.internal.DomainParameterXref;
import org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter;
import org.hibernate.query.sqm.tree.SqmStatement;
import org.hibernate.query.sqm.tree.expression.SqmExpression;
import org.hibernate.query.sqm.tree.select.SqmQuerySpec;
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
import org.hibernate.sql.ast.tree.Statement;
import org.hibernate.sql.ast.tree.expression.Expression;
import org.hibernate.sql.ast.tree.expression.Literal;
import org.hibernate.sql.ast.tree.from.StandardTableGroup;
import org.hibernate.sql.ast.tree.from.TableReference;
import org.hibernate.sql.ast.tree.select.QuerySpec;
/**
* A SQM to SQL AST translator for Informix.
*
* @author Christian Beikov
*/
public class InformixSqmToSqlAstConverter<T extends Statement> extends BaseSqmToSqlAstConverter<T> {
private boolean needsDummyTableGroup;
public InformixSqmToSqlAstConverter(
SqmStatement<?> statement,
QueryOptions queryOptions,
DomainParameterXref domainParameterXref,
QueryParameterBindings domainParameterBindings,
LoadQueryInfluencers fetchInfluencers,
SqlAstCreationContext creationContext) {
super( creationContext, statement, queryOptions, fetchInfluencers, domainParameterXref, domainParameterBindings );
}
@Override
public QuerySpec visitQuerySpec(SqmQuerySpec<?> sqmQuerySpec) {
final boolean needsDummy = this.needsDummyTableGroup;
this.needsDummyTableGroup = false;
try {
final QuerySpec querySpec = super.visitQuerySpec( sqmQuerySpec );
if ( this.needsDummyTableGroup ) {
querySpec.getFromClause().addRoot(
new StandardTableGroup(
null,
null,
null,
new TableReference(
"(select 1)",
"dummy_(x)",
false,
getCreationContext().getSessionFactory()
),
null,
getCreationContext().getSessionFactory()
)
);
}
return querySpec;
}
finally {
this.needsDummyTableGroup = needsDummy;
}
}
@Override
protected Expression resolveGroupOrOrderByExpression(SqmExpression<?> groupByClauseExpression) {
final Expression expression = super.resolveGroupOrOrderByExpression( groupByClauseExpression );
if ( expression instanceof Literal ) {
// Note that SqlAstTranslator.renderPartitionItem depends on this
this.needsDummyTableGroup = true;
}
return expression;
}
}

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
/**
* A SQL dialect for Ingres 10 and later versions.

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
/**
* A SQL dialect for Ingres 9.3 and later versions.

View File

@ -4,33 +4,47 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.GroupByConstantRenderingStrategy;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.function.CommonFunctionFactory;
import org.hibernate.dialect.identity.IdentityColumnSupport;
import org.hibernate.dialect.identity.Ingres10IdentityColumnSupport;
import org.hibernate.dialect.identity.Ingres9IdentityColumnSupport;
import org.hibernate.dialect.pagination.FirstLimitHandler;
import org.hibernate.dialect.pagination.IngresLimitHandler;
import org.hibernate.community.dialect.identity.Ingres10IdentityColumnSupport;
import org.hibernate.community.dialect.identity.Ingres9IdentityColumnSupport;
import org.hibernate.community.dialect.pagination.FirstLimitHandler;
import org.hibernate.community.dialect.pagination.IngresLimitHandler;
import org.hibernate.dialect.pagination.LimitHandler;
import org.hibernate.dialect.sequence.ANSISequenceSupport;
import org.hibernate.dialect.sequence.SequenceSupport;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
import org.hibernate.engine.spi.LoadQueryInfluencers;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
import org.hibernate.query.FetchClauseType;
import org.hibernate.query.TemporalUnit;
import org.hibernate.query.spi.QueryEngine;
import org.hibernate.query.spi.QueryOptions;
import org.hibernate.query.spi.QueryParameterBindings;
import org.hibernate.query.sqm.internal.DomainParameterXref;
import org.hibernate.query.sqm.mutation.internal.idtable.AfterUseAction;
import org.hibernate.query.sqm.mutation.internal.idtable.GlobalTemporaryTableStrategy;
import org.hibernate.query.sqm.mutation.internal.idtable.IdTable;
import org.hibernate.query.sqm.mutation.internal.idtable.TempIdTableExporter;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
import org.hibernate.query.sqm.sql.SqmTranslator;
import org.hibernate.query.sqm.sql.SqmTranslatorFactory;
import org.hibernate.query.sqm.sql.StandardSqmTranslatorFactory;
import org.hibernate.query.sqm.tree.select.SqmSelectStatement;
import org.hibernate.sql.ast.SqlAstTranslator;
import org.hibernate.sql.ast.SqlAstTranslatorFactory;
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
import org.hibernate.sql.ast.spi.StandardSqlAstTranslatorFactory;
import org.hibernate.sql.ast.tree.Statement;
import org.hibernate.sql.ast.tree.select.SelectStatement;
import org.hibernate.sql.exec.spi.JdbcOperation;
import org.hibernate.tool.schema.extract.internal.SequenceNameExtractorImpl;
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
@ -240,6 +254,29 @@ public class IngresDialect extends Dialect {
}
@Override
public SqmTranslatorFactory getSqmTranslatorFactory() {
return new StandardSqmTranslatorFactory() {
@Override
public SqmTranslator<SelectStatement> createSelectTranslator(
SqmSelectStatement<?> sqmSelectStatement,
QueryOptions queryOptions,
DomainParameterXref domainParameterXref,
QueryParameterBindings domainParameterBindings,
LoadQueryInfluencers loadQueryInfluencers,
SqlAstCreationContext creationContext) {
return new IngresSqmToSqlAstConverter<>(
sqmSelectStatement,
queryOptions,
domainParameterXref,
domainParameterBindings,
loadQueryInfluencers,
creationContext
);
}
};
}
@Override
public SqlAstTranslatorFactory getSqlAstTranslatorFactory() {
return new StandardSqlAstTranslatorFactory() {
@ -385,6 +422,24 @@ public class IngresDialect extends Dialect {
return getVersion() >= 930;
}
@Override
public boolean supportsUnionInSubquery() {
// At least not according to HHH-3637
return false;
}
@Override
public boolean supportsSubqueryInSelect() {
// At least according to HHH-4961
return getVersion() >= 1000;
}
@Override
public boolean supportsOrderByInSubquery() {
// This is just a guess
return false;
}
// Informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@Override
@ -453,4 +508,8 @@ public class IngresDialect extends Dialect {
return GroupByConstantRenderingStrategy.COLUMN_REFERENCE;
}
@Override
public boolean supportsFetchClause(FetchClauseType type) {
return getVersion() >= 930;
}
}

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
import java.util.List;
@ -119,11 +119,8 @@ public class IngresSqlAstTranslator<T extends JdbcOperation> extends AbstractSql
@Override
protected void renderPartitionItem(Expression expression) {
if ( expression instanceof Literal ) {
// todo (6.0): We need to introduce a dummy from clause item
// String fromItem = ", (select 1 x " + dialect.getFromDual() + ") dummy";
// sqlBuffer.insert( fromEndIndex, fromItem );
// appendSql( "dummy.x" );
throw new UnsupportedOperationException( "Column reference strategy is not yet implemented!" );
// Note that this depends on the SqmToSqlAstConverter to add a dummy table group
appendSql( "dummy_.x" );
}
else if ( expression instanceof Summarization ) {
// This could theoretically be emulated by rendering all grouping variations of the query and

View File

@ -0,0 +1,83 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.community.dialect;
import org.hibernate.engine.spi.LoadQueryInfluencers;
import org.hibernate.query.spi.QueryOptions;
import org.hibernate.query.spi.QueryParameterBindings;
import org.hibernate.query.sqm.internal.DomainParameterXref;
import org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter;
import org.hibernate.query.sqm.tree.SqmStatement;
import org.hibernate.query.sqm.tree.expression.SqmExpression;
import org.hibernate.query.sqm.tree.select.SqmQuerySpec;
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
import org.hibernate.sql.ast.tree.Statement;
import org.hibernate.sql.ast.tree.expression.Expression;
import org.hibernate.sql.ast.tree.expression.Literal;
import org.hibernate.sql.ast.tree.from.StandardTableGroup;
import org.hibernate.sql.ast.tree.from.TableReference;
import org.hibernate.sql.ast.tree.select.QuerySpec;
/**
* A SQM to SQL AST translator for Ingres.
*
* @author Christian Beikov
*/
public class IngresSqmToSqlAstConverter<T extends Statement> extends BaseSqmToSqlAstConverter<T> {
private boolean needsDummyTableGroup;
public IngresSqmToSqlAstConverter(
SqmStatement<?> statement,
QueryOptions queryOptions,
DomainParameterXref domainParameterXref,
QueryParameterBindings domainParameterBindings,
LoadQueryInfluencers fetchInfluencers,
SqlAstCreationContext creationContext) {
super( creationContext, statement, queryOptions, fetchInfluencers, domainParameterXref, domainParameterBindings );
}
@Override
public QuerySpec visitQuerySpec(SqmQuerySpec<?> sqmQuerySpec) {
final boolean needsDummy = this.needsDummyTableGroup;
this.needsDummyTableGroup = false;
try {
final QuerySpec querySpec = super.visitQuerySpec( sqmQuerySpec );
if ( this.needsDummyTableGroup ) {
querySpec.getFromClause().addRoot(
new StandardTableGroup(
null,
null,
null,
new TableReference(
"(select 1)",
"dummy_(x)",
false,
getCreationContext().getSessionFactory()
),
null,
getCreationContext().getSessionFactory()
)
);
}
return querySpec;
}
finally {
this.needsDummyTableGroup = needsDummy;
}
}
@Override
protected Expression resolveGroupOrOrderByExpression(SqmExpression<?> groupByClauseExpression) {
final Expression expression = super.resolveGroupOrOrderByExpression( groupByClauseExpression );
if ( expression instanceof Literal ) {
// Note that SqlAstTranslator.renderPartitionItem depends on this
this.needsDummyTableGroup = true;
}
return expression;
}
}

View File

@ -4,14 +4,16 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.AbstractTransactSQLDialect;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.function.CommonFunctionFactory;
import org.hibernate.dialect.pagination.LimitHandler;
import org.hibernate.dialect.pagination.LimitOffsetLimitHandler;
import org.hibernate.dialect.sequence.MaxDBSequenceSupport;
import org.hibernate.community.dialect.sequence.MaxDBSequenceSupport;
import org.hibernate.dialect.sequence.SequenceSupport;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.metamodel.mapping.EntityMappingType;
@ -26,7 +28,7 @@ import org.hibernate.sql.ast.SqlAstTranslatorFactory;
import org.hibernate.sql.ast.spi.StandardSqlAstTranslatorFactory;
import org.hibernate.sql.ast.tree.Statement;
import org.hibernate.sql.exec.spi.JdbcOperation;
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorSAPDBDatabaseImpl;
import org.hibernate.community.dialect.sequence.SequenceInformationExtractorSAPDBDatabaseImpl;
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptor;
@ -154,7 +156,7 @@ public class MaxDBDialect extends Dialect {
@Override
public String trimPattern(TrimSpec specification, char character) {
return AbstractTransactSQLDialect.replaceLtrimRtrim(specification, character);
return AbstractTransactSQLDialect.replaceLtrimRtrim( specification, character);
}
@Override
@ -232,6 +234,11 @@ public class MaxDBDialect extends Dialect {
return false;
}
@Override
public boolean supportsOffsetInSubquery() {
return true;
}
@Override
@SuppressWarnings("deprecation")
public CaseFragment createCaseFragment() {

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
import java.util.List;

View File

@ -4,15 +4,19 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
import org.hibernate.HibernateException;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.cfg.Environment;
import org.hibernate.community.dialect.identity.MimerSQLIdentityColumnSupport;
import org.hibernate.community.dialect.sequence.SequenceInformationExtractorMimerSQLDatabaseImpl;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.function.CommonFunctionFactory;
import org.hibernate.dialect.identity.IdentityColumnSupport;
import org.hibernate.dialect.pagination.LimitHandler;
import org.hibernate.dialect.pagination.OffsetFetchLimitHandler;
import org.hibernate.dialect.sequence.MimerSequenceSupport;
import org.hibernate.community.dialect.sequence.MimerSequenceSupport;
import org.hibernate.dialect.sequence.SequenceSupport;
import org.hibernate.engine.jdbc.Size;
import org.hibernate.engine.spi.SessionFactoryImplementor;
@ -24,7 +28,6 @@ import org.hibernate.sql.ast.SqlAstTranslatorFactory;
import org.hibernate.sql.ast.spi.StandardSqlAstTranslatorFactory;
import org.hibernate.sql.ast.tree.Statement;
import org.hibernate.sql.exec.spi.JdbcOperation;
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorMimerSQLDatabaseImpl;
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
import java.sql.Types;
@ -261,6 +264,11 @@ public class MimerSQLDialect extends Dialect {
return false;
}
@Override
public boolean supportsOffsetInSubquery() {
return true;
}
@Override
public String translateDatetimeFormat(String format) {
throw new NotYetImplementedFor6Exception("format() function not supported on Mimer SQL");
@ -270,4 +278,9 @@ public class MimerSQLDialect extends Dialect {
public boolean useInputStreamToInsertBlob() {
return false;
}
@Override
public IdentityColumnSupport getIdentityColumnSupport() {
return new MimerSQLIdentityColumnSupport();
}
}

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
import java.util.List;

View File

@ -4,14 +4,17 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
import org.hibernate.LockMode;
import org.hibernate.dialect.AbstractTransactSQLDialect;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.OracleDialect;
import org.hibernate.dialect.function.CommonFunctionFactory;
import org.hibernate.dialect.lock.*;
import org.hibernate.dialect.pagination.FetchLimitHandler;
import org.hibernate.dialect.pagination.LimitHandler;
import org.hibernate.dialect.sequence.RDMSSequenceSupport;
import org.hibernate.community.dialect.sequence.RDMSSequenceSupport;
import org.hibernate.dialect.sequence.SequenceSupport;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.CoreMessageLogger;
@ -330,6 +333,12 @@ public class RDMSOS2200Dialect extends Dialect {
return false;
}
@Override
public boolean supportsOrderByInSubquery() {
// This is just a guess
return false;
}
@Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
// RDMS has no known variation of a "SELECT ... FOR UPDATE" syntax...
@ -367,6 +376,6 @@ public class RDMSOS2200Dialect extends Dialect {
@Override
public String trimPattern(TrimSpec specification, char character) {
return AbstractTransactSQLDialect.replaceLtrimRtrim(specification, character);
return AbstractTransactSQLDialect.replaceLtrimRtrim( specification, character);
}
}

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
import java.util.List;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
/**
* @deprecated use {@link MaxDBDialect}

View File

@ -0,0 +1,617 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.community.dialect;
import java.sql.Types;
import javax.persistence.TemporalType;
import org.hibernate.ScrollMode;
import org.hibernate.community.dialect.identity.SQLiteIdentityColumnSupport;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.NationalizationSupport;
import org.hibernate.dialect.Replacer;
import org.hibernate.dialect.function.CommonFunctionFactory;
import org.hibernate.dialect.identity.IdentityColumnSupport;
import org.hibernate.dialect.pagination.LimitHandler;
import org.hibernate.dialect.pagination.LimitOffsetLimitHandler;
import org.hibernate.dialect.unique.DefaultUniqueDelegate;
import org.hibernate.dialect.unique.UniqueDelegate;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.exception.DataException;
import org.hibernate.exception.JDBCConnectionException;
import org.hibernate.exception.LockAcquisitionException;
import org.hibernate.exception.spi.SQLExceptionConversionDelegate;
import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor;
import org.hibernate.exception.spi.ViolatedConstraintNameExtractor;
import org.hibernate.internal.util.JdbcExceptionHelper;
import org.hibernate.mapping.Column;
import org.hibernate.query.NullOrdering;
import org.hibernate.query.SemanticException;
import org.hibernate.query.TemporalUnit;
import org.hibernate.query.TrimSpec;
import org.hibernate.query.spi.QueryEngine;
import org.hibernate.query.sqm.produce.function.StandardFunctionReturnTypeResolvers;
import org.hibernate.sql.ast.SqlAstNodeRenderingMode;
import org.hibernate.sql.ast.SqlAstTranslator;
import org.hibernate.sql.ast.SqlAstTranslatorFactory;
import org.hibernate.sql.ast.spi.StandardSqlAstTranslatorFactory;
import org.hibernate.sql.ast.tree.Statement;
import org.hibernate.sql.exec.spi.JdbcOperation;
import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.descriptor.jdbc.BlobTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.ClobTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptor;
import static org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor.extractUsingTemplate;
import static org.hibernate.query.TemporalUnit.DAY;
import static org.hibernate.query.TemporalUnit.EPOCH;
import static org.hibernate.query.TemporalUnit.MONTH;
import static org.hibernate.query.TemporalUnit.QUARTER;
import static org.hibernate.query.TemporalUnit.YEAR;
/**
* An SQL dialect for SQLite.
*
* @author Christian Beikov
* @author Vlad Mihalcea
*/
public class SQLiteDialect extends Dialect {
private static final SQLiteIdentityColumnSupport IDENTITY_COLUMN_SUPPORT = new SQLiteIdentityColumnSupport();
private final UniqueDelegate uniqueDelegate;
private final int version;
public SQLiteDialect(DialectResolutionInfo info) {
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() );
}
public SQLiteDialect() {
this( 200 );
}
public SQLiteDialect(int version) {
super();
this.version = version;
if ( version < 300 ) {
registerColumnType( Types.DECIMAL, "numeric($p,$s)" );
registerColumnType( Types.CHAR, "char" );
registerColumnType( Types.NCHAR, "nchar" );
}
// No precision support
registerColumnType( Types.FLOAT, "float" );
registerColumnType( Types.TIMESTAMP, "timestamp" );
registerColumnType( Types.TIMESTAMP_WITH_TIMEZONE, "timestamp" );
registerColumnType( Types.TIME_WITH_TIMEZONE, "time" );
registerColumnType( Types.BINARY, "blob" );
registerColumnType( Types.VARBINARY, "blob" );
registerColumnType( Types.LONGVARBINARY, "blob" );
uniqueDelegate = new SQLiteUniqueDelegate( this );
}
private static class SQLiteUniqueDelegate extends DefaultUniqueDelegate {
public SQLiteUniqueDelegate(Dialect dialect) {
super( dialect );
}
@Override
public String getColumnDefinitionUniquenessFragment(Column column) {
return " unique";
}
}
@Override
public UniqueDelegate getUniqueDelegate() {
return uniqueDelegate;
}
@Override
public int getVersion() {
return version;
}
/**
* The {@code extract()} function returns {@link TemporalUnit#DAY_OF_WEEK}
* numbered from 0 to 6. This isn't consistent with what most other
* databases do, so here we adjust the result by generating
* {@code (extract(dow,arg)+1))}.
*/
@Override
public String extractPattern(TemporalUnit unit) {
switch ( unit ) {
case SECOND:
return "cast(strftime('%S.%f', ?2) as double)";
case MINUTE:
return "strftime('%M', ?2)";
case HOUR:
return "strftime('%H', ?2)";
case DAY:
case DAY_OF_MONTH:
return "(strftime('%d', ?2)+1)";
case MONTH:
return "strftime('%m', ?2)";
case YEAR:
return "strftime('%Y', ?2)";
case DAY_OF_WEEK:
return "(strftime('%w', ?2)+1)";
case DAY_OF_YEAR:
return "strftime('%j', ?2)";
case EPOCH:
return "strftime('%s', ?2)";
case WEEK:
// Thanks https://stackoverflow.com/questions/15082584/sqlite-return-wrong-week-number-for-2013
return "((strftime('%j', date(?2, '-3 days', 'weekday 4'))-1)/7+1)";
default:
return super.extractPattern(unit);
}
}
@Override
public String timestampaddPattern(TemporalUnit unit, TemporalType temporalType) {
final String function = temporalType == TemporalType.DATE ? "date" : "datetime";
switch ( unit ) {
case NANOSECOND:
case NATIVE:
return "datetime(?3, '+?2 seconds')";
case QUARTER: //quarter is not supported in interval literals
return function + "(?3, '+'||(?2*3)||' months')";
case WEEK: //week is not supported in interval literals
return function + "(?3, '+'||(?2*7)||' days')";
default:
return function + "(?3, '+?2 ?1s')";
}
}
@Override
public String timestampdiffPattern(TemporalUnit unit, TemporalType fromTemporalType, TemporalType toTemporalType) {
final StringBuilder pattern = new StringBuilder();
switch ( unit ) {
case YEAR:
extractField( pattern, YEAR, unit );
break;
case QUARTER:
pattern.append( "(" );
extractField( pattern, YEAR, unit );
pattern.append( "+" );
extractField( pattern, QUARTER, unit );
pattern.append( ")" );
break;
case MONTH:
pattern.append( "(" );
extractField( pattern, YEAR, unit );
pattern.append( "+" );
extractField( pattern, MONTH, unit );
pattern.append( ")" );
break;
case WEEK: //week is not supported by extract() when the argument is a duration
case DAY:
extractField( pattern, DAY, unit );
break;
//in order to avoid multiple calls to extract(),
//we use extract(epoch from x - y) * factor for
//all the following units:
case HOUR:
case MINUTE:
case SECOND:
case NANOSECOND:
case NATIVE:
extractField( pattern, EPOCH, unit );
break;
default:
throw new SemanticException( "unrecognized field: " + unit );
}
return pattern.toString();
}
private void extractField(
StringBuilder pattern,
TemporalUnit unit,
TemporalUnit toUnit) {
final String rhs = extractPattern( unit );
final String lhs = rhs.replace( "?2", "?3" );
pattern.append( '(');
pattern.append( lhs );
pattern.append( '-' );
pattern.append( rhs );
pattern.append(")").append( unit.conversionFactor( toUnit, this ) );
}
@Override
public void initializeFunctionRegistry(QueryEngine queryEngine) {
super.initializeFunctionRegistry( queryEngine );
CommonFunctionFactory.mod_operator( queryEngine );
CommonFunctionFactory.leftRight_substr( queryEngine );
CommonFunctionFactory.concat_pipeOperator( queryEngine );
CommonFunctionFactory.characterLength_length( queryEngine, SqlAstNodeRenderingMode.DEFAULT );
CommonFunctionFactory.leastGreatest_minMax( queryEngine );
CommonFunctionFactory.radians( queryEngine );
CommonFunctionFactory.degrees( queryEngine );
CommonFunctionFactory.trunc( queryEngine );
CommonFunctionFactory.log( queryEngine );
CommonFunctionFactory.trim2( queryEngine );
CommonFunctionFactory.substr( queryEngine );
CommonFunctionFactory.substring_substr( queryEngine );
CommonFunctionFactory.chr_char( queryEngine );
queryEngine.getSqmFunctionRegistry().registerBinaryTernaryPattern(
"locate",
StandardBasicTypes.INTEGER,
"instr(?2, ?1)",
"instr(?2, ?1, ?3)"
).setArgumentListSignature("(pattern, string[, start])");
queryEngine.getSqmFunctionRegistry().registerBinaryTernaryPattern(
"lpad",
StandardBasicTypes.STRING,
"(substr(replace(hex(zeroblob(?2)), '00', ' '), 1, ?2 - length(?1))||?1)",
"(substr(replace(hex(zeroblob(?2)), '00', ?3), 1, ?2 - length(?1))||?1)"
).setArgumentListSignature("(string, length[, padding])");
queryEngine.getSqmFunctionRegistry().registerBinaryTernaryPattern(
"rpad",
StandardBasicTypes.STRING,
"(?1||substr(replace(hex(zeroblob(?2)), '00', ' '), 1, ?2 - length(?1)))",
"(?1||substr(replace(hex(zeroblob(?2)), '00', ?3), 1, ?2 - length(?1)))"
).setArgumentListSignature("(string, length[, padding])");
queryEngine.getSqmFunctionRegistry().namedDescriptorBuilder("format", "strftime")
.setInvariantType( StandardBasicTypes.STRING )
.setExactArgumentCount( 2 )
.setArgumentListSignature("(datetime as pattern)")
.register();
if (!supportsMathFunctions() ) {
queryEngine.getSqmFunctionRegistry().patternDescriptorBuilder(
"floor",
"(cast(?1 as int) - (?1 < cast(?1 as int)))"
).setReturnTypeResolver( StandardFunctionReturnTypeResolvers.useArgType( 1 ) )
.setExactArgumentCount( 1 )
.register();
queryEngine.getSqmFunctionRegistry().patternDescriptorBuilder(
"ceiling",
"(cast(?1 as int) + (?1 > cast(?1 as int)))"
).setReturnTypeResolver( StandardFunctionReturnTypeResolvers.useArgType( 1 ) )
.setExactArgumentCount( 1 )
.register();
}
}
@Override
public String trimPattern(TrimSpec specification, char character) {
switch ( specification ) {
case BOTH:
return character == ' '
? "trim(?1)"
: "trim(?1, '" + character + "')";
case LEADING:
return character == ' '
? "ltrim(?1)"
: "ltrim(?1, '" + character + "')";
case TRAILING:
return character == ' '
? "rtrim(?1)"
: "rtrim(?1, '" + character + "')";
}
throw new UnsupportedOperationException( "Unsupported specification: " + specification );
}
protected boolean supportsMathFunctions() {
// Math functions have to be enabled through a compile time option: https://www.sqlite.org/lang_mathfunc.html
return true;
}
@Override
public JdbcTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
switch (sqlCode) {
case Types.BLOB:
return BlobTypeDescriptor.PRIMITIVE_ARRAY_BINDING;
case Types.CLOB:
return ClobTypeDescriptor.STRING_BINDING;
default:
return super.getSqlTypeDescriptorOverride( sqlCode );
}
}
@Override
public LimitHandler getLimitHandler() {
return LimitOffsetLimitHandler.INSTANCE;
}
@Override
public boolean supportsLockTimeouts() {
// may be http://sqlite.org/c3ref/db_mutex.html ?
return false;
}
@Override
public String getForUpdateString() {
return "";
}
@Override
public boolean supportsOuterJoinForUpdate() {
return false;
}
@Override
public boolean supportsNullPrecedence() {
return getVersion() >= 330;
}
@Override
public NullOrdering getNullOrdering() {
return NullOrdering.SMALLEST;
}
@Override
public SqlAstTranslatorFactory getSqlAstTranslatorFactory() {
return new StandardSqlAstTranslatorFactory() {
@Override
protected <T extends JdbcOperation> SqlAstTranslator<T> buildTranslator(
SessionFactoryImplementor sessionFactory, Statement statement) {
return new SQLiteSqlAstTranslator<>( sessionFactory, statement );
}
};
}
private static final int SQLITE_BUSY = 5;
private static final int SQLITE_LOCKED = 6;
private static final int SQLITE_IOERR = 10;
private static final int SQLITE_CORRUPT = 11;
private static final int SQLITE_NOTFOUND = 12;
private static final int SQLITE_FULL = 13;
private static final int SQLITE_CANTOPEN = 14;
private static final int SQLITE_PROTOCOL = 15;
private static final int SQLITE_TOOBIG = 18;
private static final int SQLITE_CONSTRAINT = 19;
private static final int SQLITE_MISMATCH = 20;
private static final int SQLITE_NOTADB = 26;
@Override
public ViolatedConstraintNameExtractor getViolatedConstraintNameExtractor() {
return EXTRACTOR;
}
private static final ViolatedConstraintNameExtractor EXTRACTOR =
new TemplatedViolatedConstraintNameExtractor( sqle -> {
final int errorCode = JdbcExceptionHelper.extractErrorCode( sqle );
if (errorCode == SQLITE_CONSTRAINT) {
return extractUsingTemplate( "constraint ", " failed", sqle.getMessage() );
}
return null;
} );
@Override
public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate() {
return (sqlException, message, sql) -> {
final int errorCode = JdbcExceptionHelper.extractErrorCode( sqlException );
switch ( errorCode ) {
case SQLITE_TOOBIG:
case SQLITE_MISMATCH:
return new DataException( message, sqlException, sql );
case SQLITE_BUSY:
case SQLITE_LOCKED:
return new LockAcquisitionException( message, sqlException, sql );
case SQLITE_NOTADB:
return new JDBCConnectionException( message, sqlException, sql );
default:
if ( errorCode >= SQLITE_IOERR && errorCode <= SQLITE_PROTOCOL ) {
return new JDBCConnectionException( message, sqlException, sql );
}
return null;
}
};
}
// Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@Override
public boolean supportsEmptyInList() {
return false;
}
// DDL support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@Override
public boolean canCreateSchema() {
return false;
}
@Override
public boolean hasAlterTable() {
// As specified in NHibernate dialect
return false;
}
@Override
public boolean dropConstraints() {
return false;
}
@Override
public boolean qualifyIndexName() {
return false;
}
@Override
public String getDropForeignKeyString() {
throw new UnsupportedOperationException( "No drop foreign key syntax supported by SQLiteDialect" );
}
@Override
public String getAddForeignKeyConstraintString(
String constraintName,
String[] foreignKey,
String referencedTable,
String[] primaryKey,
boolean referencesPrimaryKey) {
throw new UnsupportedOperationException( "No add foreign key syntax supported by SQLiteDialect" );
}
@Override
public String getAddPrimaryKeyConstraintString(String constraintName) {
throw new UnsupportedOperationException( "No add primary key syntax supported by SQLiteDialect" );
}
@Override
public boolean supportsCommentOn() {
return true;
}
@Override
public boolean supportsIfExistsBeforeTableName() {
return true;
}
@Override
public boolean doesReadCommittedCauseWritersToBlockReaders() {
// TODO Validate (WAL mode...)
return true;
}
@Override
public boolean doesRepeatableReadCauseReadersToBlockWriters() {
return true;
}
@Override
public boolean supportsTupleDistinctCounts() {
return false;
}
public int getInExpressionCountLimit() {
// Compile/runtime time option: http://sqlite.org/limits.html#max_variable_number
return 1000;
}
@Override
public boolean supportsWindowFunctions() {
return true;
}
@Override
public IdentityColumnSupport getIdentityColumnSupport() {
return IDENTITY_COLUMN_SUPPORT;
}
@Override
public String getSelectGUIDString() {
return "select hex(randomblob(16))";
}
@Override
public ScrollMode defaultScrollMode() {
return ScrollMode.FORWARD_ONLY;
}
@Override
public String getNoColumnsInsertString() {
return "default values";
}
@Override
public NationalizationSupport getNationalizationSupport() {
return NationalizationSupport.IMPLICIT;
}
@Override
public String currentDate() {
return "date('now')";
}
@Override
public String currentTime() {
return "time('now')";
}
@Override
public String currentTimestamp() {
return "datetime('now')";
}
@Override
public String translateDatetimeFormat(String format) {
return datetimeFormat( format ).result();
}
public static Replacer datetimeFormat(String format) {
return new Replacer( format, "'", "" )
.replace("%", "%%")
//year
.replace("yyyy", "%Y")
.replace("yyy", "%Y")
.replace("yy", "%y") //?????
.replace("y", "%y") //?????
//month of year
.replace("MMMM", "%B") //?????
.replace("MMM", "%b") //?????
.replace("MM", "%m")
.replace("M", "%m") //?????
//day of week
.replace("EEEE", "%A") //?????
.replace("EEE", "%a") //?????
.replace("ee", "%w")
.replace("e", "%w") //?????
//day of month
.replace("dd", "%d")
.replace("d", "%d") //?????
//am pm
.replace("aa", "%p") //?????
.replace("a", "%p") //?????
//hour
.replace("hh", "%I") //?????
.replace("HH", "%H")
.replace("h", "%I") //?????
.replace("H", "%H") //?????
//minute
.replace("mm", "%M")
.replace("m", "%M") //?????
//second
.replace("ss", "%S")
.replace("s", "%S") //?????
//fractional seconds
.replace("SSSSSS", "%f") //5 is the max
.replace("SSSSS", "%f")
.replace("SSSS", "%f")
.replace("SSS", "%f")
.replace("SS", "%f")
.replace("S", "%f");
}
@Override
public String translateExtractField(TemporalUnit unit) {
// All units should be handled in extractPattern so we should never hit this method
throw new UnsupportedOperationException( "Unsupported unit: " + unit );
}
@Override
protected String wrapDateLiteral(String date) {
return "date(" + date + ")";
}
@Override
protected String wrapTimeLiteral(String time) {
return "time(" + time + ")";
}
@Override
protected String wrapTimestampLiteral(String timestamp) {
return "datetime(" + timestamp + ")";
}
}

View File

@ -0,0 +1,151 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.community.dialect;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.query.ComparisonOperator;
import org.hibernate.sql.ast.spi.AbstractSqlAstTranslator;
import org.hibernate.sql.ast.tree.Statement;
import org.hibernate.sql.ast.tree.cte.CteMaterialization;
import org.hibernate.sql.ast.tree.cte.CteStatement;
import org.hibernate.sql.ast.tree.expression.Any;
import org.hibernate.sql.ast.tree.expression.Every;
import org.hibernate.sql.ast.tree.expression.Expression;
import org.hibernate.sql.ast.tree.expression.Summarization;
import org.hibernate.sql.ast.tree.select.QueryGroup;
import org.hibernate.sql.ast.tree.select.QueryPart;
import org.hibernate.sql.ast.tree.select.QuerySpec;
import org.hibernate.sql.exec.spi.JdbcOperation;
/**
* A SQL AST translator for SQLite.
*
* @author Christian Beikov
* @author Vlad Mihalcea
*/
public class SQLiteSqlAstTranslator<T extends JdbcOperation> extends AbstractSqlAstTranslator<T> {
public SQLiteSqlAstTranslator(SessionFactoryImplementor sessionFactory, Statement statement) {
super( sessionFactory, statement );
}
@Override
protected LockStrategy determineLockingStrategy(
QuerySpec querySpec,
ForUpdateClause forUpdateClause,
Boolean followOnLocking) {
return LockStrategy.NONE;
}
@Override
protected void renderForUpdateClause(QuerySpec querySpec, ForUpdateClause forUpdateClause) {
// SQLite does not support the FOR UPDATE clause
}
@Override
protected void renderMaterializationHint(CteMaterialization materialization) {
if ( getDialect().getVersion() >= 335 ) {
if ( materialization == CteMaterialization.NOT_MATERIALIZED ) {
appendSql( "not " );
}
appendSql( "materialized " );
}
}
@Override
public boolean supportsFilterClause() {
return getDialect().getVersion() >= 330;
}
@Override
protected boolean supportsQuantifiedPredicates() {
return false;
}
protected boolean shouldEmulateFetchClause(QueryPart queryPart) {
// Check if current query part is already row numbering to avoid infinite recursion
// We also have to emulate this if a fetch clause type other than rows only is used
return getQueryPartForRowNumbering() != queryPart && !isRowsOnlyFetchClauseType( queryPart );
}
@Override
public void visitQueryGroup(QueryGroup queryGroup) {
if ( shouldEmulateFetchClause( queryGroup ) ) {
emulateFetchOffsetWithWindowFunctions( queryGroup, true );
}
else {
super.visitQueryGroup( queryGroup );
}
}
@Override
public void visitQuerySpec(QuerySpec querySpec) {
if ( shouldEmulateFetchClause( querySpec ) ) {
emulateFetchOffsetWithWindowFunctions( querySpec, true );
}
else {
super.visitQuerySpec( querySpec );
}
}
@Override
public void visitOffsetFetchClause(QueryPart queryPart) {
if ( !isRowNumberingCurrentQueryPart() ) {
renderLimitOffsetClause( queryPart );
}
}
@Override
protected void renderSearchClause(CteStatement cte) {
// SQLite does not support this, but it's just a hint anyway
}
@Override
protected void renderCycleClause(CteStatement cte) {
// SQLite does not support this, but it can be emulated
}
@Override
protected void renderComparison(Expression lhs, ComparisonOperator operator, Expression rhs) {
if ( rhs instanceof Any ) {
emulateSubQueryRelationalRestrictionPredicate(
null,
false,
( (Any) rhs ).getSubquery(),
lhs,
this::renderSelectSimpleComparison,
operator
);
}
else if ( rhs instanceof Every ) {
emulateSubQueryRelationalRestrictionPredicate(
null,
true,
( (Every) rhs ).getSubquery(),
lhs,
this::renderSelectSimpleComparison,
operator.negated()
);
}
else {
renderComparisonDistinctOperator( lhs, operator, rhs );
}
}
@Override
protected void renderPartitionItem(Expression expression) {
if ( expression instanceof Summarization ) {
// This could theoretically be emulated by rendering all grouping variations of the query and
// connect them via union all but that's probably pretty inefficient and would have to happen
// on the query spec level
throw new UnsupportedOperationException( "Summarization is not supported by DBMS!" );
}
else {
expression.accept( this );
}
}
}

View File

@ -4,12 +4,15 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
import org.hibernate.LockOptions;
import org.hibernate.dialect.GroupByConstantRenderingStrategy;
import org.hibernate.dialect.RowLockStrategy;
import org.hibernate.dialect.SybaseDialect;
import org.hibernate.dialect.identity.IdentityColumnSupport;
import org.hibernate.dialect.identity.SybaseAnywhereIdentityColumnSupport;
import org.hibernate.community.dialect.identity.SybaseAnywhereIdentityColumnSupport;
import org.hibernate.dialect.pagination.LimitHandler;
import org.hibernate.dialect.pagination.TopLimitHandler;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
@ -31,15 +34,18 @@ import java.util.Map;
public class SybaseAnywhereDialect extends SybaseDialect {
public SybaseAnywhereDialect() {
this( 800 );
this( 800, false );
}
public SybaseAnywhereDialect(DialectResolutionInfo info){
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
this(
info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10,
info.getDriverName() != null && info.getDriverName().contains( "jTDS" )
);
}
public SybaseAnywhereDialect(int version) {
super( version );
public SybaseAnywhereDialect(int version, boolean jtdsDriver) {
super( version, jtdsDriver );
registerColumnType( Types.BIGINT, "bigint" );
registerColumnType( Types.DATE, "date" );

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
import java.util.List;
@ -72,7 +72,7 @@ public class SybaseAnywhereSqlAstTranslator<T extends JdbcOperation> extends Abs
@Override
protected void visitSqlSelections(SelectClause selectClause) {
if ( getDialect().getVersion() < 900 ) {
renderTopClause( (QuerySpec) getQueryPartStack().getCurrent(), true );
renderTopClause( (QuerySpec) getQueryPartStack().getCurrent(), true, true );
}
else {
renderTopStartAtClause( (QuerySpec) getQueryPartStack().getCurrent() );
@ -81,9 +81,9 @@ public class SybaseAnywhereSqlAstTranslator<T extends JdbcOperation> extends Abs
}
@Override
protected void renderTopClause(QuerySpec querySpec, boolean addOffset) {
protected void renderTopClause(QuerySpec querySpec, boolean addOffset, boolean needsParenthesis) {
assertRowsOnlyFetchClauseType( querySpec );
super.renderTopClause( querySpec, addOffset );
super.renderTopClause( querySpec, addOffset, needsParenthesis );
}
@Override

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
/**
* A dialect for the Teradata 14

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
import org.hibernate.LockOptions;
import org.hibernate.boot.Metadata;
@ -12,9 +12,11 @@ import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.relational.QualifiedNameImpl;
import org.hibernate.boot.model.relational.QualifiedTableName;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.GroupByConstantRenderingStrategy;
import org.hibernate.dialect.function.CommonFunctionFactory;
import org.hibernate.dialect.identity.IdentityColumnSupport;
import org.hibernate.dialect.identity.Teradata14IdentityColumnSupport;
import org.hibernate.community.dialect.identity.Teradata14IdentityColumnSupport;
import org.hibernate.dialect.pagination.LimitHandler;
import org.hibernate.dialect.pagination.TopLimitHandler;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
@ -65,7 +67,7 @@ import static org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtract
*/
public class TeradataDialect extends Dialect {
private int version;
private final int version;
private static final int PARAM_LIST_SIZE_LIMIT = 1024;
@ -348,6 +350,12 @@ public class TeradataDialect extends Dialect {
return false;
}
@Override
public boolean supportsOrderByInSubquery() {
// This is just a guess
return false;
}
@Override
public String getSelectClauseNullString(int sqlType) {
String v = "null";

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
import java.util.List;
@ -89,7 +89,7 @@ public class TeradataSqlAstTranslator<T extends JdbcOperation> extends AbstractS
@Override
protected void visitSqlSelections(SelectClause selectClause) {
renderTopClause( (QuerySpec) getQueryPartStack().getCurrent(), true );
renderTopClause( (QuerySpec) getQueryPartStack().getCurrent(), true, true );
super.visitSqlSelections( selectClause );
}

View File

@ -4,17 +4,19 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
import org.hibernate.LockMode;
import org.hibernate.LockOptions;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.RowLockStrategy;
import org.hibernate.dialect.function.CommonFunctionFactory;
import org.hibernate.dialect.lock.*;
import org.hibernate.dialect.pagination.LimitHandler;
import org.hibernate.dialect.pagination.TimesTenLimitHandler;
import org.hibernate.community.dialect.pagination.TimesTenLimitHandler;
import org.hibernate.dialect.sequence.SequenceSupport;
import org.hibernate.dialect.sequence.TimesTenSequenceSupport;
import org.hibernate.community.dialect.sequence.TimesTenSequenceSupport;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
@ -31,7 +33,7 @@ import org.hibernate.sql.ast.SqlAstTranslatorFactory;
import org.hibernate.sql.ast.spi.StandardSqlAstTranslatorFactory;
import org.hibernate.sql.ast.tree.Statement;
import org.hibernate.sql.exec.spi.JdbcOperation;
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorTimesTenDatabaseImpl;
import org.hibernate.community.dialect.sequence.SequenceInformationExtractorTimesTenDatabaseImpl;
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptor;
@ -279,6 +281,11 @@ public class TimesTenDialect extends Dialect {
return false;
}
@Override
public boolean supportsOffsetInSubquery() {
return true;
}
@Override
public LimitHandler getLimitHandler() {
return TimesTenLimitHandler.INSTANCE;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
import java.util.List;
@ -12,6 +12,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.query.ComparisonOperator;
import org.hibernate.query.IllegalQueryOperationException;
import org.hibernate.query.SemanticException;
import org.hibernate.sql.ast.SqlAstJoinType;
import org.hibernate.sql.ast.spi.AbstractSqlAstTranslator;
import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.ast.tree.Statement;
@ -54,6 +55,16 @@ public class TimesTenSqlAstTranslator<T extends JdbcOperation> extends AbstractS
return strategy;
}
@Override
protected void renderJoinType(SqlAstJoinType joinType) {
if ( joinType == SqlAstJoinType.CROSS ) {
appendSql( ", " );
}
else {
super.renderJoinType( joinType );
}
}
@Override
protected void renderSearchClause(CteStatement cte) {
// TimesTen does not support this, but it's just a hint anyway

View File

@ -4,7 +4,9 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect.identity;
package org.hibernate.community.dialect.identity;
import org.hibernate.dialect.identity.IdentityColumnSupportImpl;
/**
* @author Andrea Boriero

View File

@ -4,9 +4,10 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect.identity;
package org.hibernate.community.dialect.identity;
import org.hibernate.MappingException;
import org.hibernate.dialect.identity.IdentityColumnSupportImpl;
/**
* @author Andrea Boriero

View File

@ -4,7 +4,9 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect.identity;
package org.hibernate.community.dialect.identity;
import org.hibernate.dialect.identity.IdentityColumnSupportImpl;
/**
* @author Mark Rotteveel

View File

@ -4,11 +4,12 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect.identity;
package org.hibernate.community.dialect.identity;
import java.sql.Types;
import org.hibernate.MappingException;
import org.hibernate.dialect.identity.IdentityColumnSupportImpl;
/**
* @author Andrea Boriero

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect.identity;
package org.hibernate.community.dialect.identity;
/**
* @author Andrea Boriero

View File

@ -4,7 +4,9 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect.identity;
package org.hibernate.community.dialect.identity;
import org.hibernate.dialect.identity.IdentityColumnSupportImpl;
/**
* @author Andrea Boriero

View File

@ -4,7 +4,9 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect.identity;
package org.hibernate.community.dialect.identity;
import org.hibernate.dialect.identity.IdentityColumnSupportImpl;
/**
* @author Andrea Boriero

View File

@ -4,25 +4,35 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect.identity;
package org.hibernate.community.dialect.identity;
import org.hibernate.dialect.identity.IdentityColumnSupportImpl;
/**
* See https://sqlite.org/autoinc.html and
* https://github.com/nhibernate/nhibernate-core/blob/master/src/NHibernate/Dialect/SQLiteDialect.cs for details.
*
* @author Andrea Boriero
*/
public class JDataStoreIdentityColumnSupport extends IdentityColumnSupportImpl {
public class SQLiteIdentityColumnSupport extends IdentityColumnSupportImpl {
@Override
public boolean supportsIdentityColumns() {
return true;
}
@Override
public String getIdentitySelectString(String table, String column, int type) {
// NOT_SUPPORTED_SHOULD_USE_JDBC3_PreparedStatement.getGeneratedKeys_method
return null;
public boolean hasDataTypeInIdentityColumn() {
return false;
}
@Override
public String getIdentityColumnString(int type) {
return "autoincrement";
return "integer";
}
@Override
public String getIdentitySelectString(String table, String column, int type) {
return "select last_insert_rowid()";
}
}

View File

@ -4,7 +4,9 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect.identity;
package org.hibernate.community.dialect.identity;
import org.hibernate.dialect.identity.AbstractTransactSQLIdentityColumnSupport;
/**
* @author Andrea Boriero

View File

@ -4,7 +4,9 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect.identity;
package org.hibernate.community.dialect.identity;
import org.hibernate.dialect.identity.IdentityColumnSupportImpl;
/**
* @author Andrea Boriero

View File

@ -4,7 +4,10 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect.pagination;
package org.hibernate.community.dialect.pagination;
import org.hibernate.dialect.pagination.AbstractNoOffsetLimitHandler;
import org.hibernate.dialect.pagination.LimitHandler;
/**
* A {@link LimitHandler} for older versions of Informix, Ingres,

View File

@ -4,10 +4,13 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect.pagination;
package org.hibernate.community.dialect.pagination;
import java.util.regex.Pattern;
import org.hibernate.dialect.pagination.LimitHandler;
import org.hibernate.dialect.pagination.OffsetFetchLimitHandler;
/**
* A {@link LimitHandler} for Ingres. According to the
* documentation for Ingres 10.2, Ingres supports the
@ -32,10 +35,10 @@ public class IngresLimitHandler extends OffsetFetchLimitHandler {
}
@Override
boolean isIngres() {
protected boolean renderOffsetRowsKeyword() {
//Ingres doesn't like "rows" in the
//ANSI-standard syntax 'offset n rows'
return true;
return false;
}
private static final String[] WITH_OPTIONS = {

View File

@ -4,10 +4,13 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect.pagination;
package org.hibernate.community.dialect.pagination;
import java.util.regex.Pattern;
import org.hibernate.dialect.pagination.AbstractSimpleLimitHandler;
import org.hibernate.dialect.pagination.LimitHandler;
import static java.util.regex.Pattern.CASE_INSENSITIVE;
import static java.util.regex.Pattern.compile;

View File

@ -4,8 +4,10 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect.pagination;
package org.hibernate.community.dialect.pagination;
import org.hibernate.dialect.pagination.AbstractLimitHandler;
import org.hibernate.dialect.pagination.LimitHandler;
import org.hibernate.engine.spi.RowSelection;
import org.hibernate.query.Limit;
@ -17,7 +19,7 @@ public class SkipFirstLimitHandler extends AbstractLimitHandler {
public static final SkipFirstLimitHandler INSTANCE = new SkipFirstLimitHandler(true);
private boolean variableLimit;
private final boolean variableLimit;
public SkipFirstLimitHandler(boolean variableLimit) {
this.variableLimit = variableLimit;

View File

@ -4,7 +4,9 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect.pagination;
package org.hibernate.community.dialect.pagination;
import org.hibernate.dialect.pagination.LimitHandler;
/**
* A {@link LimitHandler} for TimesTen, which uses {@code ROWS n},

View File

@ -4,10 +4,12 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect.sequence;
package org.hibernate.community.dialect.sequence;
import org.hibernate.dialect.sequence.SequenceSupport;
/**
* Sequence support for {@link org.hibernate.dialect.CUBRIDDialect}.
* Sequence support for {@link org.hibernate.community.dialect.CUBRIDDialect}.
*
* @author Gavin King
*/
@ -20,6 +22,11 @@ public final class CUBRIDSequenceSupport implements SequenceSupport {
return sequenceName + ".next_value";
}
@Override
public String getSelectSequencePreviousValString(String sequenceName) {
return sequenceName + ".current_value";
}
@Override
public String getFromDual() {
//TODO: is this really needed?

View File

@ -4,10 +4,12 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect.sequence;
package org.hibernate.community.dialect.sequence;
import org.hibernate.dialect.sequence.SequenceSupport;
/**
* Sequence support for {@link org.hibernate.dialect.CacheDialect}.
* Sequence support for {@link org.hibernate.community.dialect.CacheDialect}.
*
* Use of sequences on Cache is not recommended.
*

View File

@ -4,10 +4,14 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect.sequence;
package org.hibernate.community.dialect.sequence;
import org.hibernate.MappingException;
import org.hibernate.dialect.sequence.ANSISequenceSupport;
import org.hibernate.dialect.sequence.SequenceSupport;
/**
* Sequence support for {@link org.hibernate.dialect.FirebirdDialect}
* Sequence support for {@link org.hibernate.community.dialect.FirebirdDialect}
* on Firebird 3.
*
* @author Gavin King
@ -52,4 +56,9 @@ public class FirebirdSequenceSupport extends ANSISequenceSupport {
return " from rdb$database";
}
@Override
public String getSelectSequencePreviousValString(String sequenceName) throws MappingException {
return "gen_id(" + sequenceName + ",0)";
}
}

View File

@ -4,10 +4,13 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect.sequence;
package org.hibernate.community.dialect.sequence;
import org.hibernate.dialect.sequence.NextvalSequenceSupport;
import org.hibernate.dialect.sequence.SequenceSupport;
/**
* Sequence support for {@link org.hibernate.dialect.InformixDialect}.
* Sequence support for {@link org.hibernate.community.dialect.InformixDialect}.
*
* @author Gavin King
*/

View File

@ -4,10 +4,12 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect.sequence;
package org.hibernate.community.dialect.sequence;
import org.hibernate.dialect.sequence.SequenceSupport;
/**
* Sequence support for {@link org.hibernate.dialect.FirebirdDialect}
* Sequence support for {@link org.hibernate.community.dialect.FirebirdDialect}
* on Firebird 2.
*
* @author Gavin King
@ -35,6 +37,11 @@ public final class InterbaseSequenceSupport implements SequenceSupport {
return "gen_id(" + sequenceName + "," + increment + ")";
}
@Override
public String getSelectSequencePreviousValString(String sequenceName) {
return getSelectSequenceNextValString( sequenceName, 0 );
}
@Override
public String[] getCreateSequenceStrings(String sequenceName, int initialValue, int incrementSize) {
return initialValue == 1

View File

@ -4,9 +4,11 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect.sequence;
package org.hibernate.community.dialect.sequence;
import org.hibernate.dialect.MaxDBDialect;
import org.hibernate.community.dialect.MaxDBDialect;
import org.hibernate.dialect.sequence.NextvalSequenceSupport;
import org.hibernate.dialect.sequence.SequenceSupport;
/**
* Sequence support for {@link MaxDBDialect}.

View File

@ -4,10 +4,14 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect.sequence;
package org.hibernate.community.dialect.sequence;
import org.hibernate.community.dialect.MimerSQLDialect;
import org.hibernate.dialect.sequence.ANSISequenceSupport;
import org.hibernate.dialect.sequence.SequenceSupport;
/**
* Sequence support for {@link org.hibernate.dialect.MimerSQLDialect}.
* Sequence support for {@link MimerSQLDialect}.
*
* @author Gavin King
*/

View File

@ -4,12 +4,13 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect.sequence;
package org.hibernate.community.dialect.sequence;
import org.hibernate.MappingException;
import org.hibernate.dialect.sequence.SequenceSupport;
/**
* Sequence support for {@link org.hibernate.dialect.RDMSOS2200Dialect}.
* Sequence support for {@link org.hibernate.community.dialect.RDMSOS2200Dialect}.
*
* Note that RDMS doesn't really have sequences as such, but it does
* have the GUID-like {@code permuted_id()} and {@code unique_id()}

View File

@ -4,7 +4,9 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.tool.schema.extract.internal;
package org.hibernate.community.dialect.sequence;
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl;
/**
* @author Vlad Mihalcea

View File

@ -4,7 +4,9 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.tool.schema.extract.internal;
package org.hibernate.community.dialect.sequence;
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl;
/**
* @author Mark Rotteveel

View File

@ -4,7 +4,9 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.tool.schema.extract.internal;
package org.hibernate.community.dialect.sequence;
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl;
/**
* @author Vlad Mihalcea

View File

@ -4,7 +4,9 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.tool.schema.extract.internal;
package org.hibernate.community.dialect.sequence;
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl;
/**
* @author Vlad Mihalcea

View File

@ -4,7 +4,9 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.tool.schema.extract.internal;
package org.hibernate.community.dialect.sequence;
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl;
/**
* @author Vlad Mihalcea

View File

@ -4,7 +4,9 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.tool.schema.extract.internal;
package org.hibernate.community.dialect.sequence;
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl;
/**
* @author Vlad Mihalcea

View File

@ -4,7 +4,9 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.tool.schema.extract.internal;
package org.hibernate.community.dialect.sequence;
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl;
/**
* @author Vlad Mihalcea

View File

@ -4,10 +4,13 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect.sequence;
package org.hibernate.community.dialect.sequence;
import org.hibernate.dialect.sequence.NextvalSequenceSupport;
import org.hibernate.dialect.sequence.SequenceSupport;
/**
* Sequence support for {@link org.hibernate.dialect.TimesTenDialect}.
* Sequence support for {@link org.hibernate.community.dialect.TimesTenDialect}.
*
* @author Gavin King
*/

View File

@ -4,10 +4,11 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect.unique;
package org.hibernate.community.dialect.unique;
import org.hibernate.boot.Metadata;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.unique.DefaultUniqueDelegate;
import org.hibernate.mapping.UniqueKey;
/**

View File

@ -0,0 +1 @@
org.hibernate.community.dialect.CommunityDialectSelector

View File

@ -0,0 +1 @@
org.hibernate.community.dialect.CommunityDialectResolver

View File

@ -0,0 +1,93 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.community.dialect;
import java.util.Properties;
import org.hibernate.boot.registry.BootstrapServiceRegistry;
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfoSource;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolver;
import org.hibernate.orm.test.dialect.resolver.TestingDialectResolutionInfo;
import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* @author Steve Ebersole
*/
public class CommunityDialectFactoryTest extends BaseUnitTestCase {
private StandardServiceRegistry registry;
private DialectFactoryImpl dialectFactory;
@Before
public void setUp() {
final BootstrapServiceRegistry bootReg = new BootstrapServiceRegistryBuilder().applyClassLoader(
CommunityDialectFactoryTest.class.getClassLoader()
).build();
registry = new StandardServiceRegistryBuilder( bootReg ).build();
dialectFactory = new DialectFactoryImpl();
dialectFactory.injectServices( (ServiceRegistryImplementor) registry );
}
@Test
public void testPreregisteredDialects() {
DialectResolver resolver = new CommunityDialectResolver();
testDetermination( "Ingres", IngresDialect.class, resolver );
testDetermination( "ingres", IngresDialect.class, resolver );
testDetermination( "INGRES", IngresDialect.class, resolver );
testDetermination( "Adaptive Server Anywhere", SybaseAnywhereDialect.class, resolver );
testDetermination( "Informix Dynamic Server", InformixDialect.class, resolver );
}
private void testDetermination(String databaseName, Class expected, DialectResolver resolver) {
testDetermination( databaseName, -9999, expected, resolver );
}
private void testDetermination(String databaseName, int databaseMajorVersion, Class expected, DialectResolver resolver) {
testDetermination( databaseName, databaseMajorVersion, -9999, expected, resolver );
}
private void testDetermination(
final String databaseName,
final int majorVersion,
final int minorVersion,
Class expected,
DialectResolver resolver) {
testDetermination( databaseName, null, majorVersion, minorVersion, expected, resolver );
}
private void testDetermination(
final String databaseName,
final String driverName,
final int majorVersion,
final int minorVersion,
Class expected,
DialectResolver resolver) {
dialectFactory.setDialectResolver( resolver );
Dialect resolved = dialectFactory.buildDialect(
new Properties(),
new DialectResolutionInfoSource() {
@Override
public DialectResolutionInfo getDialectResolutionInfo() {
return TestingDialectResolutionInfo.forDatabaseInfo( databaseName, driverName, majorVersion, minorVersion );
}
}
);
assertEquals( expected, resolved.getClass() );
}
}

View File

@ -0,0 +1,44 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.community.dialect;
import org.hibernate.dialect.Dialect;
import org.junit.Assert;
import org.junit.Test;
public class CommunityDialectSelectorTest {
private final CommunityDialectSelector strategySelector = new CommunityDialectSelector();
@Test
public void verifyAllDialectNamingResolve() {
testDialectNamingResolution( Cache71Dialect.class );
testDialectNamingResolution( CUBRIDDialect.class );
testDialectNamingResolution( FirebirdDialect.class );
testDialectNamingResolution( InformixDialect.class );
testDialectNamingResolution( IngresDialect.class );
testDialectNamingResolution( Ingres9Dialect.class );
testDialectNamingResolution( Ingres10Dialect.class );
testDialectNamingResolution( MimerSQLDialect.class );
testDialectNamingResolution( SAPDBDialect.class );
testDialectNamingResolution( SybaseAnywhereDialect.class );
testDialectNamingResolution( TeradataDialect.class );
testDialectNamingResolution( TimesTenDialect.class );
}
private void testDialectNamingResolution(final Class<?> dialectClass) {
String simpleName = dialectClass.getSimpleName();
if ( simpleName.endsWith( "Dialect" ) ) {
simpleName = simpleName.substring( 0, simpleName.length() - "Dialect".length() );
}
Class<? extends Dialect> aClass = strategySelector.resolve( simpleName );
Assert.assertNotNull( aClass );
Assert.assertEquals( dialectClass, aClass );
}
}

View File

@ -4,14 +4,11 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.orm.test.dialect;
package org.hibernate.community.dialect;
import java.util.Collections;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.boot.registry.internal.BootstrapServiceRegistryImpl;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.InformixDialect;
import org.hibernate.jpa.JpaComplianceStub;
import org.hibernate.metamodel.model.domain.internal.JpaMetamodelImpl;
import org.hibernate.query.criteria.ValueHandlingMode;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.orm.test.query.hql;
package org.hibernate.community.dialect;
import java.sql.Timestamp;
import java.util.Calendar;
@ -14,8 +14,6 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import org.hibernate.dialect.InformixDialect;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.RequiresDialect;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.orm.test.dialect.functional.cache;
package org.hibernate.community.dialect.functional.cache;
import java.sql.Connection;
import java.sql.SQLException;
@ -17,7 +17,7 @@ import java.util.HashSet;
import java.util.List;
import org.hibernate.LockOptions;
import org.hibernate.dialect.CacheDialect;
import org.hibernate.community.dialect.CacheDialect;
import org.hibernate.query.Query;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;

View File

@ -9,7 +9,7 @@
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.hibernate.test.dialect.functional.cache" >
<hibernate-mapping package="org.hibernate.community.dialect.functional.cache" >
<class name="TestInterSystemsFunctionsClass" table="SQLUser.TestInterSystemsFunctionsClass">
<id name="id" type="long" column="id_">

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.orm.test.dialect.functional.cache;
package org.hibernate.community.dialect.functional.cache;
import java.util.Date;
/**

View File

@ -0,0 +1,45 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.boot.registry.selector.internal;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.hibernate.boot.registry.selector.spi.DialectSelector;
import org.hibernate.dialect.Dialect;
public class AggregatedDialectSelector implements DialectSelector {
private final List<DialectSelector> dialectSelectors;
public AggregatedDialectSelector(Iterable<DialectSelector> dialectSelectorProvider) {
final List<DialectSelector> dialectSelectors = new ArrayList<>();
for ( DialectSelector dialectSelector : dialectSelectorProvider ) {
dialectSelectors.add( dialectSelector );
}
dialectSelectors.add( new DefaultDialectSelector() );
this.dialectSelectors = dialectSelectors;
}
@Override
public Class<? extends Dialect> resolve(final String name) {
Objects.requireNonNull( name );
if ( name.isEmpty() ) {
return null;
}
for ( DialectSelector dialectSelector : dialectSelectors ) {
final Class<? extends Dialect> dialectClass = dialectSelector.resolve( name );
if ( dialectClass != null ) {
return dialectClass;
}
}
return null;
}
}

View File

@ -8,9 +8,7 @@ package org.hibernate.boot.registry.selector.internal;
import java.util.Objects;
import org.hibernate.dialect.CUBRIDDialect;
import org.hibernate.dialect.Cache71Dialect;
import org.hibernate.dialect.CacheDialect;
import org.hibernate.boot.registry.selector.spi.DialectSelector;
import org.hibernate.dialect.CockroachDialect;
import org.hibernate.dialect.DB2390Dialect;
import org.hibernate.dialect.DB2390V8Dialect;
@ -25,24 +23,16 @@ import org.hibernate.dialect.DerbyTenFiveDialect;
import org.hibernate.dialect.DerbyTenSevenDialect;
import org.hibernate.dialect.DerbyTenSixDialect;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.FirebirdDialect;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.dialect.HANACloudColumnStoreDialect;
import org.hibernate.dialect.HANAColumnStoreDialect;
import org.hibernate.dialect.HANARowStoreDialect;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.Informix10Dialect;
import org.hibernate.dialect.InformixDialect;
import org.hibernate.dialect.Ingres10Dialect;
import org.hibernate.dialect.Ingres9Dialect;
import org.hibernate.dialect.IngresDialect;
import org.hibernate.dialect.MariaDB102Dialect;
import org.hibernate.dialect.MariaDB103Dialect;
import org.hibernate.dialect.MariaDB10Dialect;
import org.hibernate.dialect.MariaDB53Dialect;
import org.hibernate.dialect.MariaDBDialect;
import org.hibernate.dialect.MaxDBDialect;
import org.hibernate.dialect.MimerSQLDialect;
import org.hibernate.dialect.MySQL55Dialect;
import org.hibernate.dialect.MySQL57Dialect;
import org.hibernate.dialect.MySQL5Dialect;
@ -63,8 +53,6 @@ import org.hibernate.dialect.PostgreSQL95Dialect;
import org.hibernate.dialect.PostgreSQL9Dialect;
import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.dialect.PostgresPlusDialect;
import org.hibernate.dialect.RDMSOS2200Dialect;
import org.hibernate.dialect.SAPDBDialect;
import org.hibernate.dialect.SQLServer2005Dialect;
import org.hibernate.dialect.SQLServer2008Dialect;
import org.hibernate.dialect.SQLServer2012Dialect;
@ -74,29 +62,19 @@ import org.hibernate.dialect.Sybase11Dialect;
import org.hibernate.dialect.SybaseASE157Dialect;
import org.hibernate.dialect.SybaseASE15Dialect;
import org.hibernate.dialect.SybaseASEDialect;
import org.hibernate.dialect.SybaseAnywhereDialect;
import org.hibernate.dialect.SybaseDialect;
import org.hibernate.dialect.Teradata14Dialect;
import org.hibernate.dialect.TeradataDialect;
import org.hibernate.dialect.TimesTenDialect;
public class DefaultDialectSelector implements LazyServiceResolver<Dialect> {
public class DefaultDialectSelector implements DialectSelector {
@Override
public Class<? extends Dialect> resolve(final String name) {
Objects.requireNonNull( name);
Objects.requireNonNull( name );
if ( name.isEmpty() ) {
return null;
}
switch ( name ) {
case "Cache":
return CacheDialect.class;
case "Cache71":
return Cache71Dialect.class;
case "Cockroach":
return CockroachDialect.class;
case "CUBRID":
return CUBRIDDialect.class;
case "DB2":
return DB2Dialect.class;
case "DB2i":
@ -121,8 +99,6 @@ public class DefaultDialectSelector implements LazyServiceResolver<Dialect> {
return DerbyTenSixDialect.class;
case "DerbyTenSeven":
return DerbyTenSevenDialect.class;
case "Firebird":
return FirebirdDialect.class;
case "H2":
return H2Dialect.class;
case "HANACloudColumnStore":
@ -133,16 +109,6 @@ public class DefaultDialectSelector implements LazyServiceResolver<Dialect> {
return HANARowStoreDialect.class;
case "HSQL":
return HSQLDialect.class;
case "Informix":
return InformixDialect.class;
case "Informix10":
return Informix10Dialect.class;
case "Ingres":
return IngresDialect.class;
case "Ingres9":
return Ingres9Dialect.class;
case "Ingres10":
return Ingres10Dialect.class;
case "MariaDB":
return MariaDBDialect.class;
case "MariaDB53":
@ -153,10 +119,6 @@ public class DefaultDialectSelector implements LazyServiceResolver<Dialect> {
return MariaDB102Dialect.class;
case "MariaDB103":
return MariaDB103Dialect.class;
case "MaxDB":
return MaxDBDialect.class;
case "MimerSQL":
return MimerSQLDialect.class;
case "MySQL":
return MySQLDialect.class;
case "MySQL5":
@ -197,10 +159,6 @@ public class DefaultDialectSelector implements LazyServiceResolver<Dialect> {
return PostgreSQL94Dialect.class;
case "PostgreSQL95":
return PostgreSQL95Dialect.class;
case "RDMSOS2200":
return RDMSOS2200Dialect.class;
case "SAPDB":
return SAPDBDialect.class;
case "Spanner":
return SpannerDialect.class;
case "SQLServer":
@ -215,20 +173,12 @@ public class DefaultDialectSelector implements LazyServiceResolver<Dialect> {
return SybaseDialect.class;
case "Sybase11":
return Sybase11Dialect.class;
case "SybaseAnywhere":
return SybaseAnywhereDialect.class;
case "SybaseASE":
return SybaseASEDialect.class;
case "SybaseASE15":
return SybaseASE15Dialect.class;
case "SybaseASE157":
return SybaseASE157Dialect.class;
case "Teradata":
return TeradataDialect.class;
case "Teradata14":
return Teradata14Dialect.class;
case "TimesTen":
return TimesTenDialect.class;
}
return null;
}

View File

@ -18,6 +18,7 @@ import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.selector.SimpleStrategyRegistrationImpl;
import org.hibernate.boot.registry.selector.StrategyRegistration;
import org.hibernate.boot.registry.selector.StrategyRegistrationProvider;
import org.hibernate.boot.registry.selector.spi.DialectSelector;
import org.hibernate.boot.registry.selector.spi.StrategySelectionException;
import org.hibernate.boot.registry.selector.spi.StrategySelector;
import org.hibernate.cache.internal.DefaultCacheKeysFactory;
@ -97,7 +98,10 @@ public class StrategySelectorBuilder {
final StrategySelectorImpl strategySelector = new StrategySelectorImpl( classLoaderService );
// build the baseline...
strategySelector.registerStrategyLazily( Dialect.class, new DefaultDialectSelector() );
strategySelector.registerStrategyLazily(
Dialect.class,
new AggregatedDialectSelector( classLoaderService.loadJavaServices( DialectSelector.class ) )
);
strategySelector.registerStrategyLazily( JtaPlatform.class, new DefaultJtaPlatformSelector() );
addTransactionCoordinatorBuilders( strategySelector );
addSqmMultiTableMutationStrategies( strategySelector );

View File

@ -0,0 +1,39 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.boot.registry.selector.spi;
import java.util.Collection;
import java.util.concurrent.Callable;
import org.hibernate.boot.registry.selector.internal.LazyServiceResolver;
import org.hibernate.dialect.Dialect;
import org.hibernate.service.Service;
/**
* Service which acts as a registry for named strategy implementations.
* <p/>
* Strategies are more open ended than services, though a strategy managed here might very well also be a service. The
* strategy is any interface that has multiple, (possibly short) named implementations.
* <p/>
* StrategySelector manages resolution of particular implementation by (possibly short) name via the
* {@link #selectStrategyImplementor} method, which is the main contract here. As indicated in the docs of that
* method the given name might be either a short registered name or the implementation FQN. As an example, consider
* resolving the {@link org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder} implementation to use. To use the
* JDBC-based TransactionCoordinatorBuilder the passed name might be either {@code "jdbc"} or
* {@code "org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorBuilderImpl"} (which is the FQN).
* <p/>
* Strategy implementations can be managed by {@link #registerStrategyImplementor} and
* {@link #unRegisterStrategyImplementor}. Originally designed to help the OSGi use case, though no longer used there.
* <p/>
* The service also exposes a general typing API via {@link #resolveStrategy} and {@link #resolveDefaultableStrategy}
* which accept implementation references rather than implementation names, allowing for a multitude of interpretations
* of said "implementation reference". See the docs for {@link #resolveDefaultableStrategy} for details.
*
* @author Christian Beikov
*/
public interface DialectSelector extends Service, LazyServiceResolver<Dialect> {
}

View File

@ -1523,6 +1523,16 @@ public abstract class AbstractHANADialect extends Dialect {
return 0;
}
@Override
public boolean supportsOffsetInSubquery() {
return true;
}
@Override
public boolean supportsWindowFunctions() {
return true;
}
@Override
public boolean supportsNoWait() {
return true;

View File

@ -24,6 +24,7 @@ import org.hibernate.query.sqm.mutation.internal.idtable.IdTable;
import org.hibernate.query.sqm.mutation.internal.idtable.LocalTemporaryTableStrategy;
import org.hibernate.query.sqm.mutation.internal.idtable.TempIdTableExporter;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeDescriptorRegistry;
@ -39,7 +40,7 @@ import java.util.Map;
*
* @author Gavin King
*/
abstract class AbstractTransactSQLDialect extends Dialect {
public abstract class AbstractTransactSQLDialect extends Dialect {
public AbstractTransactSQLDialect() {
super();
@ -122,7 +123,7 @@ abstract class AbstractTransactSQLDialect extends Dialect {
return replaceLtrimRtrim(specification, character);
}
static String replaceLtrimRtrim(TrimSpec specification, char character) {
public static String replaceLtrimRtrim(TrimSpec specification, char character) {
boolean blank = character == ' ';
switch ( specification ) {
case LEADING:
@ -314,4 +315,9 @@ abstract class AbstractTransactSQLDialect extends Dialect {
public boolean supportsPartitionBy() {
return true;
}
@Override
public String formatBinaryLiteral(byte[] bytes) {
return "0x" + StandardBasicTypes.BINARY.toString( bytes );
}
}

View File

@ -481,6 +481,16 @@ public class CockroachDialect extends Dialect {
return false;
}
@Override
public boolean supportsOffsetInSubquery() {
return true;
}
@Override
public boolean supportsWindowFunctions() {
return true;
}
@Override
public boolean supportsNoWait() {
return getVersion() >= 2010;

Some files were not shown because too many files have changed in this diff Show More