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

cryptic error when providing import.sql file without ; at the end of each line #3817

Closed
emmanuelbernard opened this issue Sep 3, 2019 · 10 comments
Labels
area/persistence kind/bug Something isn't working
Milestone

Comments

@emmanuelbernard
Copy link
Member

Adding

INSERT INTO todo(id, title, completed, ordering, url) VALUES (nextval('hibernate_sequence'), 'Introduction to Quarkus', true, 0, null)
INSERT INTO todo(id, title, completed, ordering, url) VALUES (nextval('hibernate_sequence'), 'Hibernate with Panache', false, 1, null)
INSERT INTO todo(id, title, completed, ordering, url) VALUES (nextval('hibernate_sequence'), 'Visit Quarkus web site', false, 2, 'https://quarkus.io')
INSERT INTO todo(id, title, completed, ordering, url) VALUES (nextval('hibernate_sequence'), 'Star Quarkus project', false, 3, 'https://github.com/quarkusio/quarkus/')
INSERT INTO todo(id, title, completed, ordering, url) VALUES (nextval('hibernate_sequence'), 'Star Quarkus project 2', false, 3, 'https://github.com/quarkusio/quarkus/')
INSERT INTO todo(id, title, completed, ordering, url) VALUES (nextval('hibernate_sequence'), 'Star Quarkus project 3', false, 3, 'https://github.com/quarkusio/quarkus/')
INSERT INTO todo(id, title, completed, ordering, url) VALUES (nextval('hibernate_sequence'), 'Star Quarkus project 4', false, 3, 'https://github.com/quarkusio/quarkus/')
INSERT INTO todo(id, title, completed, ordering, url) VALUES (nextval('hibernate_sequence'), 'Star Quarkus project 5', false, 3, 'https://github.com/quarkusio/quarkus/')
INSERT INTO todo(id, title, completed, ordering, url) VALUES (nextval('hibernate_sequence'), 'Star Quarkus project 6', false, 3, 'https://github.com/quarkusio/quarkus/')

Leads to a cryptic

2019-09-03 14:12:43,946 ERROR [io.qua.dev.DevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: Failed to start quarkus
        at io.quarkus.runner.ApplicationImpl1.doStart(ApplicationImpl1.zig:193)
        at io.quarkus.runtime.Application.start(Application.java:84)
        at io.quarkus.runner.RuntimeRunner.run(RuntimeRunner.java:127)
        at io.quarkus.dev.DevModeMain.doStart(DevModeMain.java:180)
        at io.quarkus.dev.DevModeMain.start(DevModeMain.java:94)
        at io.quarkus.dev.DevModeMain.main(DevModeMain.java:66)
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
        at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.persistenceException(FastBootEntityManagerFactoryBuilder.java:113)
        at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.build(FastBootEntityManagerFactoryBuilder.java:67)
        at io.quarkus.hibernate.orm.runtime.FastBootHibernatePersistenceProvider.createEntityManagerFactory(FastBootHibernatePersistenceProvider.java:54)
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
        at io.quarkus.hibernate.orm.runtime.JPAConfig$LazyPersistenceUnit.get(JPAConfig.java:109)
        at io.quarkus.hibernate.orm.runtime.JPAConfig.startAll(JPAConfig.java:57)
        at io.quarkus.hibernate.orm.runtime.HibernateOrmRecorder.startAllPersistenceUnits(HibernateOrmRecorder.java:77)
        at io.quarkus.deployment.steps.HibernateOrmProcessor$startPersistenceUnits19.deploy_0(HibernateOrmProcessor$startPersistenceUnits19.zig:51)
        at io.quarkus.deployment.steps.HibernateOrmProcessor$startPersistenceUnits19.deploy(HibernateOrmProcessor$startPersistenceUnits19.zig:70)
        at io.quarkus.runner.ApplicationImpl1.doStart(ApplicationImpl1.zig:149)
        ... 5 more
Caused by: org.hibernate.tool.hbm2ddl.ImportScriptException: Error during import script parsing.
        at org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor.extractCommands(MultipleLinesSqlCommandExtractor.java:31)
        at org.hibernate.tool.schema.internal.exec.AbstractScriptSourceInput.read(AbstractScriptSourceInput.java:40)
        at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applyImportSources(SchemaCreatorImpl.java:491)
        at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation(SchemaCreatorImpl.java:180)
        at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:135)
        at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:121)
        at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:156)
        at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:73)
        at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:315)
        at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:462)
        at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.build(FastBootEntityManagerFactoryBuilder.java:65)
        ... 14 more
Caused by: org.hibernate.hql.internal.antlr.SqlStatementParser$StatementParserException: line 1:1440: expecting STMT_END, found 'null'
        at org.hibernate.hql.internal.antlr.SqlStatementParser.throwExceptionIfErrorOccurred(SqlStatementParser.java:53)
        at org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor.extractCommands(MultipleLinesSqlCommandExtractor.java:28)
        ... 24 more

Also it seems adding the ; while in live coding does not fix the issue. I had to stop and restart Quarkus.

@emmanuelbernard emmanuelbernard added kind/bug Something isn't working area/persistence labels Sep 3, 2019
@gsmet
Copy link
Member

gsmet commented Oct 7, 2019

The second issue is fixed but it would be nice if we could improve the error message somehow.

@gsmet gsmet added this to To do in Deprecated - Quarkus 1.0 via automation Oct 7, 2019
@aguibert
Copy link
Member

hi @gsmet, I can have a go at fixing this issue

@gsmet
Copy link
Member

gsmet commented Oct 16, 2019

I think @dreab8 already has a solution for that one. @dreab8 , can you confirm?

@aguibert
Copy link
Member

hi @emmanuelbernard, what version of Quarkus were you using in this code example? I tried to reproduce the issue using 0.25.0 and also the latest 999-SNAPSHOT (as of writing this) and was not able to reproduce the issue -- the init script always ran fine for me.

Here is the exact script I used:

import.sql

insert into Gift(name, id) values ('Gift 1', nextval ('giftSeq'))
insert into Gift(name, id) values ('Gift 2', nextval ('giftSeq'))
insert into Gift(name, id) values ('Gift 3', nextval ('giftSeq'))

@dreab8
Copy link
Contributor

dreab8 commented Oct 17, 2019

I managed to reproduce it and I opened https://hibernate.atlassian.net/browse/HHH-13673 , working on it

@emmanuelbernard
Copy link
Member Author

emmanuelbernard commented Oct 17, 2019 via email

@dreab8
Copy link
Contributor

dreab8 commented Oct 17, 2019

@emmanuelbernard the exception comes from the antlr parser, it looks for one of the following terminal chars ';' , ' ' , '\t ' , '\r' , '\n'

@dreab8
Copy link
Contributor

dreab8 commented Oct 17, 2019

@gsmet here the PR hibernate/hibernate-orm#3071

@aguibert
Copy link
Member

@emmanuelbernard yea it ran for me, I pushed the code to this repo to recreate. Looks like @dreab8 has it fixed though so no further need to investigate

@Sanne Sanne added this to the 0.27.0 milestone Oct 23, 2019
@Sanne
Copy link
Member

Sanne commented Oct 23, 2019

I confirm this was fixed by #4717

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/persistence kind/bug Something isn't working
Projects
No open projects
Development

No branches or pull requests

5 participants