Volodymyr Levytskyi
Volodymyr Levytskyi

Reputation: 437

Error executing sql script with hibernate.hbm2ddl.import_files?

I use h2 db and hibernate 4.

I want to autogenerate db schema from entities and fill in db from import.sql file . Here is relevant hibernate.cfg.xml:

<!-- automatically generate database tables from hibernate entities -->
        <property name="hibernate.hbm2ddl.auto">create-drop</property>
        <!-- initialize db on startup -->
        <property name="hibernate.hbm2ddl.import_files">/import.sql</property>

So when database tables are generated import.sql is called. Here is the first sql statement:

insert into Borrower values (1,"Greece, Aphines, Square street",5,"Antonio");

When hibernate runs this sql statement it gives an error:

    квіт 23, 2015 8:56:43 PM org.hibernate.tool.hbm2ddl.SchemaExport importScript
    ERROR: HHH000388: Unsuccessful: insert into Borrower values (1,"Greece, Aphines, Square street",5,"Antonio")
    квіт 23, 2015 8:56:43 PM org.hibernate.tool.hbm2ddl.SchemaExport importScript
    Column "Greece, Aphines, Square street" not found; SQL statement:
insert into Borrower values (1,"Greece, Aphines, Square street",5,"Antonio") [42122-186]

Adding column names inside insert into statement doesn't help.

This seems to be error of h2 database.

What means this error?

Upvotes: 1

Views: 2638

Answers (1)

David Doan
David Doan

Reputation: 129

Try it with replace doulbe quote by single quote as below:

insert into Borrower values (1,'Greece, Aphines, Square street',5,'Antonio');

Upvotes: 6

Related Questions