Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HHH-10668 - Add SQL dialect for SQLite 3 #1874

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ ObjectStore
# Additional databases used in local envs
databases/mysql/
databases/postgis/

1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ subprojects { subProject ->
testRuntime( libraries.mariadb )
testRuntime( libraries.mssql )
testRuntime( libraries.informix )
testRuntime( libraries.sqlite )

if (db.equalsIgnoreCase("oracle")) {
dependencies {
Expand Down
7 changes: 7 additions & 0 deletions databases.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ ext {
'jdbc.user' : 'informix',
'jdbc.pass' : 'in4mix',
'jdbc.url' : 'jdbc:informix-sqli://192.168.99.100:9088/sysuser:INFORMIXSERVER=dev;user=informix;password=in4mix'
],
sqlite : [
'db.dialect' : 'org.hibernate.dialect.SQLiteDialect',
'jdbc.driver': 'org.sqlite.JDBC',
'jdbc.user' : 'hibernate_orm_test',
'jdbc.pass' : 'hibernate_orm_test',
'jdbc.url' : 'jdbc:sqlite:target/sqlite_test.db'
]
]
}
1 change: 1 addition & 0 deletions documentation/documentation.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ dependencies {
testRuntime( libraries.mysql )
testRuntime( libraries.mariadb )
testRuntime( libraries.mssql )
testRuntime( libraries.sqlite )

if (db.equalsIgnoreCase("oracle")) {
dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import org.hibernate.Session;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

import org.hibernate.testing.DialectCheck;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
import org.junit.Test;

import org.jboss.logging.Logger;
Expand Down Expand Up @@ -112,6 +115,7 @@ public void testFlushAutoSQL() {
}

@Test
@RequiresDialectFeature(DialectChecks.DoesNotPrefersIdentityOverSequence.class)
public void testFlushAutoSQLNativeSession() {
doInJPA( this::entityManagerFactory, entityManager -> {
entityManager.createNativeQuery( "delete from Person" ).executeUpdate();;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.hibernate.Session;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
import org.junit.Test;

import org.jboss.logging.Logger;
Expand All @@ -44,6 +46,7 @@ protected Class<?>[] getAnnotatedClasses() {
}

@Test
@RequiresDialectFeature(DialectChecks.DoesNotPrefersIdentityOverSequence.class)
public void testFlushSQL() {
doInJPA( this::entityManagerFactory, entityManager -> {
entityManager.createNativeQuery("delete from Person").executeUpdate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.hibernate.dialect.Oracle8iDialect;
import org.hibernate.dialect.PostgreSQL81Dialect;
import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.SQLiteDialect;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.type.StringType;
import org.hibernate.userguide.model.AddressType;
Expand Down Expand Up @@ -861,6 +862,7 @@ public void test_hql_api_scroll_projection_example() {
}

@Test
@SkipForDialect(SQLiteDialect.class)
public void test_hql_api_scroll_open_example() {
ScrollableResults scrollableResults = doInJPA( this::entityManagerFactory, entityManager -> {
Session session = entityManager.unwrap( Session.class );
Expand Down Expand Up @@ -1037,6 +1039,7 @@ public void test_hql_numeric_arithmetic_example_1() {
}

@Test
@SkipForDialect(value = SQLiteDialect.class, comment = "EXTRACT function is not supported")
public void test_hql_numeric_arithmetic_example_2() {
doInJPA( this::entityManagerFactory, entityManager -> {
//tag::hql-numeric-arithmetic-example[]
Expand All @@ -1053,6 +1056,7 @@ public void test_hql_numeric_arithmetic_example_2() {
}

@Test
@SkipForDialect(value = SQLiteDialect.class, comment = "EXTRACT function is not supported")
public void test_hql_numeric_arithmetic_example_3() {
doInJPA( this::entityManagerFactory, entityManager -> {
//tag::hql-numeric-arithmetic-example[]
Expand Down Expand Up @@ -1348,6 +1352,7 @@ public void test_hql_cast_function_example() {
}

@Test
@SkipForDialect(value = SQLiteDialect.class, comment = "EXTRACT function is not supported")
public void test_hql_extract_function_example() {
doInJPA( this::entityManagerFactory, entityManager -> {
//tag::hql-extract-function-example[]
Expand All @@ -1361,6 +1366,7 @@ public void test_hql_extract_function_example() {
}

@Test
@SkipForDialect(value = SQLiteDialect.class, comment = "EXTRACT function is not supported")
public void test_hql_year_function_example() {
doInJPA( this::entityManagerFactory, entityManager -> {
//tag::hql-year-function-example[]
Expand Down Expand Up @@ -1469,6 +1475,7 @@ public void test_hql_collection_expressions_example_4() {
}

@Test
@SkipForDialect(value = SQLiteDialect.class, comment = "SOME operator is not supported")
public void test_hql_collection_expressions_example_5() {
doInJPA( this::entityManagerFactory, entityManager -> {
Call call = entityManager.createQuery( "select c from Call c", Call.class).getResultList().get( 0 );
Expand Down Expand Up @@ -1517,6 +1524,7 @@ public void test_hql_collection_expressions_example_7() {
}

@Test
@SkipForDialect(value = SQLiteDialect.class, comment = "ALL operator is not supported")
public void test_hql_collection_expressions_example_8() {
doInJPA( this::entityManagerFactory, entityManager -> {
//tag::hql-collection-expressions-example[]
Expand Down Expand Up @@ -1934,6 +1942,7 @@ public void test_hql_relational_comparisons_example_7() {
}

@Test
@SkipForDialect(value = SQLiteDialect.class, comment = "ALL operator is not supported")
public void test_hql_all_subquery_comparison_qualifier_example() {

doInJPA( this::entityManagerFactory, entityManager -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.hibernate.annotations.Nationalized;
import org.hibernate.dialect.MySQL5Dialect;
import org.hibernate.dialect.PostgreSQL81Dialect;
import org.hibernate.dialect.SQLiteDialect;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

import org.hibernate.testing.SkipForDialect;
Expand All @@ -27,7 +28,8 @@
@SkipForDialect(
value = {
PostgreSQL81Dialect.class,
MySQL5Dialect.class
MySQL5Dialect.class,
SQLiteDialect.class
},
comment = "@see https://hibernate.atlassian.net/browse/HHH-10693 and https://hibernate.atlassian.net/browse/HHH-10695"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.hibernate.annotations.Nationalized;
import org.hibernate.dialect.MySQL5Dialect;
import org.hibernate.dialect.PostgreSQL81Dialect;
import org.hibernate.dialect.SQLiteDialect;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

import org.hibernate.testing.SkipForDialect;
Expand All @@ -27,7 +28,8 @@
@SkipForDialect(
value = {
PostgreSQL81Dialect.class,
MySQL5Dialect.class
MySQL5Dialect.class,
SQLiteDialect.class
},
comment = "@see https://hibernate.atlassian.net/browse/HHH-10693 and https://hibernate.atlassian.net/browse/HHH-10695"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.hibernate.annotations.Nationalized;
import org.hibernate.dialect.MySQL5Dialect;
import org.hibernate.dialect.PostgreSQL81Dialect;
import org.hibernate.dialect.SQLiteDialect;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

import org.hibernate.testing.SkipForDialect;
Expand All @@ -34,7 +35,8 @@
@SkipForDialect(
value = {
PostgreSQL81Dialect.class,
MySQL5Dialect.class
MySQL5Dialect.class,
SQLiteDialect.class
},
comment = "@see https://hibernate.atlassian.net/browse/HHH-10693 and https://hibernate.atlassian.net/browse/HHH-10695"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import org.hibernate.annotations.Nationalized;
import org.hibernate.dialect.PostgreSQL81Dialect;
import org.hibernate.dialect.SQLiteDialect;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

import org.hibernate.testing.SkipForDialect;
Expand All @@ -24,7 +25,8 @@
*/
@SkipForDialect(
value = {
PostgreSQL81Dialect.class
PostgreSQL81Dialect.class,
SQLiteDialect.class
},
comment = "@see https://hibernate.atlassian.net/browse/HHH-10693"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
import org.hibernate.annotations.Parameter;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
import org.junit.Test;

import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;

/**
* @author Vlad Mihalcea
*/
@RequiresDialectFeature( { DialectChecks.SupportsSequences.class, DialectChecks.DoesNotPrefersIdentityOverSequence.class } )
public class PooledOptimizerTest extends BaseEntityManagerFunctionalTestCase {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public String determineGeneratorName(GenerationType generationType, GeneratorNam
return UUIDGenerator.class.getName();
}
else {
return org.hibernate.id.enhanced.SequenceStyleGenerator.class.getName();
return "auto";
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import org.hibernate.dialect.PostgresPlusDialect;
import org.hibernate.dialect.ProgressDialect;
import org.hibernate.dialect.SAPDBDialect;
import org.hibernate.dialect.SQLiteDialect;
import org.hibernate.dialect.SQLServer2005Dialect;
import org.hibernate.dialect.SQLServer2008Dialect;
import org.hibernate.dialect.SQLServerDialect;
Expand Down Expand Up @@ -224,6 +225,7 @@ private void addDialects(StrategySelectorImpl strategySelector) {
addDialect( strategySelector, PostgreSQL9Dialect.class );
addDialect( strategySelector, ProgressDialect.class );
addDialect( strategySelector, SAPDBDialect.class );
addDialect( strategySelector, SQLiteDialect.class );
addDialect( strategySelector, SQLServerDialect.class );
addDialect( strategySelector, SQLServer2005Dialect.class );
addDialect( strategySelector, SQLServer2008Dialect.class );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,15 @@ public boolean supportsSequences() {
return false;
}

/**
* By default, SEQUENCE is preferred over IDENTITY.
*
* @return is IDENTITY preferred
*/
public boolean prefersIdentityOverSequence() {
return false;
}

/**
* Does this dialect support "pooled" sequences. Not aware of a better
* name for this. Essentially can we specify the initial and increment values?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
break;
}
case Types.CLOB: {
descriptor = ClobTypeDescriptor.POSTGRESQL_CLOB_BINDING;
descriptor = ClobTypeDescriptor.STRING_CLOB_BINDING;
break;
}
default: {
Expand Down
Loading