0

I am using Hibernate with PostgreSQL. I have an import.sql file that Hibernate executes after the schema is created/validated. It worked under MariaDB, but under PostgreSQL it is not. Tables and constraints are created, but the data is not imported. Here is a sample of the recurring error:

20:24:00,034 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 119) HHH000388: Unsuccessful: INSERT INTO jcat.Student (id,childcare,birthdate,name,class_id)
VALUES (1,
    FALSE,
    "1992-09-15",
    "Douglas",
    1)
20:24:00,034 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 119) ERROR: column "1992-09-15" does not exist

It happens in every insert statement. I don't know if single or double quotes are interchangeable, but I tried using both in my import file and none worked. The error log shows that single quotes are converted to double quotes (as you can see above). Maybe there is a Hibernate property I don't know about?

Software versions are PostgreSQL 9.5 and Wildfly 9 with provided Hibernate (most likely 4).

  • I have no idea right now but could you please rerun your test with a null date? It it works, you probably have a problem on date format... If it then failed on "Douglas"... sorry... dunno :p – farvilain Apr 05 '16 at 00:28
  • It fails on every string, trying to interpret them as columns. Anyway, I just fixed it, even though the solution is not very satisfactory. – Douglas De Rizzo Meneghetti Apr 05 '16 at 00:51

1 Answers1

0

I solved my problem by updating Hibernate from 4.3 to 5.1.0.Final. I had an additional error when trying to import my SQL file, but I fixed it by removing antlr from my Maven dependencies, like so:

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>5.1.0.Final</version>
        <exclusions>
            <exclusion>
                <groupId>antlr</groupId>
                <artifactId>antlr</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
Community
  • 1
  • 1