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?
尝试用单引号替换doulbe引号,如下所示:
insert into Borrower values (1,'Greece, Aphines, Square street',5,'Antonio');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.