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

Conversation

vladmihalcea
Copy link
Contributor

@vladmihalcea
Copy link
Contributor Author

@luca-vercelli I fixed the tests in the documentation folder. However, there are several issues that prevent us for integrating it:

  1. Foreign Keys don't work at all. Traditionally, we added FKs using an ALTER TABLE command, but that's not working with SQLite.
  2. There is no way we can spawn two EntityManager instances and operate with 2 JDBC Connections concomitantly. This affects all TABLE generator tests and also Lock-related tests.

Until a fix is proposed at least for the FK issue, we should postpone this integration.

@luca-vercelli
Copy link

Yes, I know that ALTER TABLE ADD FK is not supported. Foreign keys must be declared during table definition, see https://sqlite.org/foreignkeys.html.
I can work on this. Can you tell me which parts of code I should look at? Where can I find tests for you issues 1. and 2.?
Thank you.

A possible solution for 1. is not to declare at all foreign keys.

@vladmihalcea
Copy link
Contributor Author

@luca-vercelli Take a look on org.hibernate.tool.schema.internal.StandardTableExporter and StandardForeignKeyExporter which are now used to create the tables and the FK during hbm2ddl.

The Dialect already provides a way to customize them via the:

public Exporter<Table> getTableExporter() {
	return tableExporter;
}

public Exporter<ForeignKey> getForeignKeyExporter() {
	return foreignKeyExporter;
}

methods. We need to a way to export the FK in the Table exporter and just have a no-op getForeignKeyExporter.

For 2. We just need to exclude the tests that are causing failures, like LockModeTest. Check out this PR to know how you can do it. Look for @SkipForDialect annotation. You can work on top of this PR, and send a new PR when you are done.

@luca-vercelli
Copy link

I have big problems here... I cannot even compile hibernate anymore. The JVM hangs after a random number of tests.

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f91ba2acd73, pid=15684, tid=0x00007f91f0efe700
#
# JRE version: OpenJDK Runtime Environment (8.0_121-b13) (build 1.8.0_121-8u121-b13-0ubuntu1.16.04.2-b13)
# Java VM: OpenJDK 64-Bit Server VM (25.121-b13 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  [sqlite-3.16.1-770159f8-1443-427b-bca0-e3aeccc14285-libsqlitejdbc.so+0x79d73]
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/luca/Documenti/src/hibernate-orm/hibernate-core/hs_err_pid15684.log
22:55:54,230  WARN CachingRegionFactory:52 - CachingRegionFactory should be only used for testing.
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

1670 tests completed, 39 failed, 162 skipped
:hibernate-core:test FAILED

I don't know what is changed, when I sent my previous PR I had not so many tests. there were 369 tests and they worked.

@vladmihalcea
Copy link
Contributor Author

Maybe it's an OpenJDK bug. I'm using Oracle JDK and it's working just fine.

@luca-vercelli
Copy link

Same problem with Oracle JDK.
I'm building on Linux Mint (i.e. Ubuntu), on AMD64 architecture.
It seems to be a bug in sqlite JDBC (it creates a library in /tmp/sqlite-xxx-libsqlitejdbc.so ).

@cristianrgreco
Copy link

Would love to see official SQLite support in Hibernate

@cybermerlin
Copy link

hey, guys, how much time need to allow this merge request?

@beikov
Copy link
Member

beikov commented Mar 3, 2021

We are discussing the way forward for new Dialects in #3783

When we reach a conclusion, we might pick up this Dialect again.

@beikov beikov closed this Mar 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants