Rutton
unread,May 24, 2011, 6:36:41 AM5/24/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to H2 Database
Hello there,
I am new to web programming. I am playing with a little example with
h2, hibernate etc.
Now I am stuck with a problem during hibernate hbm2ddl schema creation
and a h2 database error I don't understand.
I googled this but haven't found anything appropriate on how to fix
these errors. Hopefully someone can help me with this.
Regards,
R.
The error report is the following:
12:15:11,660 INFO org.hibernate.dialect.Dialect - Using dialect:
org.hibernate.dialect.H2Dialect
12:15:11,685 INFO org.hibernate.tool.hbm2ddl.SchemaExport - Running
hbm2ddl schema export
12:15:11,686 INFO org.hibernate.tool.hbm2ddl.SchemaExport - exporting
generated schema to database
12:15:11,688 INFO
org.hibernate.connection.DriverManagerConnectionProvider - Using
Hibernate built-in connection pool (not for production use!)
12:15:11,688 INFO
org.hibernate.connection.DriverManagerConnectionProvider - Hibernate
connection pool size: 20
12:15:11,688 INFO
org.hibernate.connection.DriverManagerConnectionProvider - autocommit
mode: false
12:15:11,692 INFO
org.hibernate.connection.DriverManagerConnectionProvider - using
driver: org.h2.Driver at URL: jdbc:h2:./database
12:15:11,692 INFO
org.hibernate.connection.DriverManagerConnectionProvider - connection
properties: {user=sa, password=****}
alter table Forum_Group drop constraint FK4F0581A12889F7E4;
alter table Forum_Group drop constraint FK4F0581A19D88FC19;
alter table Group_Article drop constraint FK6A3E42F69F0F1759;
alter table Group_Article drop constraint FK6A3E42F6BEE90D92;
drop table Article if exists;
drop table Forum if exists;
drop table Forum_Group if exists;
drop table Group if exists;
drop table Group_Article if exists;
create table Article (id bigint generated by default as identity,
author varchar(255), content varchar(4096), primary key (id));
create table Forum (id bigint generated by default as identity, title
varchar(255), primary key (id));
create table Forum_Group (Forum_id bigint not null, groups_id bigint
not null, unique (groups_id));
create table Group (id bigint generated by default as identity, title
varchar(255), primary key (id));
12:15:12,035 ERROR org.hibernate.tool.hbm2ddl.SchemaExport -
Unsuccessful: create table Group (id bigint generated by default as
identity, title varchar(255), primary key (id))
12:15:12,035 ERROR org.hibernate.tool.hbm2ddl.SchemaExport - Syntax
Fehler in SQL Befehl "CREATE TABLE GROUP[*] (ID BIGINT GENERATED BY
DEFAULT AS IDENTITY, TITLE VARCHAR(255), PRIMARY KEY (ID)) "; erwartet
"identifier"
Syntax error in SQL statement "CREATE TABLE GROUP[*] (ID BIGINT
GENERATED BY DEFAULT AS IDENTITY, TITLE VARCHAR(255), PRIMARY KEY
(ID)) "; expected "identifier"; SQL statement:
create table Group (id bigint generated by default as identity, title
varchar(255), primary key (id)) [42001-154]
create table Group_Article (Group_id bigint not null, articles_id
bigint not null, unique (articles_id));
alter table Forum_Group add constraint FK4F0581A12889F7E4 foreign key
(groups_id) references Group;
12:15:12,036 ERROR org.hibernate.tool.hbm2ddl.SchemaExport -
Unsuccessful: alter table Forum_Group add constraint
FK4F0581A12889F7E4 foreign key (groups_id) references Group
12:15:12,037 ERROR org.hibernate.tool.hbm2ddl.SchemaExport - Syntax
Fehler in SQL Befehl "ALTER TABLE FORUM_GROUP ADD CONSTRAINT
FK4F0581A12889F7E4 FOREIGN KEY (GROUPS_ID) REFERENCES GROUP[*] ";
erwartet "identifier"
Syntax error in SQL statement "ALTER TABLE FORUM_GROUP ADD CONSTRAINT
FK4F0581A12889F7E4 FOREIGN KEY (GROUPS_ID) REFERENCES GROUP[*] ";
expected "identifier"; SQL statement:
alter table Forum_Group add constraint FK4F0581A12889F7E4 foreign key
(groups_id) references Group [42001-154]
alter table Forum_Group add constraint FK4F0581A19D88FC19 foreign key
(Forum_id) references Forum;
alter table Group_Article add constraint FK6A3E42F69F0F1759 foreign
key (Group_id) references Group;
12:15:12,062 ERROR org.hibernate.tool.hbm2ddl.SchemaExport -
Unsuccessful: alter table Group_Article add constraint
FK6A3E42F69F0F1759 foreign key (Group_id) references Group
12:15:12,062 ERROR org.hibernate.tool.hbm2ddl.SchemaExport - Syntax
Fehler in SQL Befehl "ALTER TABLE GROUP_ARTICLE ADD CONSTRAINT
FK6A3E42F69F0F1759 FOREIGN KEY (GROUP_ID) REFERENCES GROUP[*] ";
erwartet "identifier"
Syntax error in SQL statement "ALTER TABLE GROUP_ARTICLE ADD
CONSTRAINT FK6A3E42F69F0F1759 FOREIGN KEY (GROUP_ID) REFERENCES
GROUP[*] "; expected "identifier"; SQL statement:
alter table Group_Article add constraint FK6A3E42F69F0F1759 foreign
key (Group_id) references Group [42001-154]
alter table Group_Article add constraint FK6A3E42F6BEE90D92 foreign
key (articles_id) references Article;
12:15:12,064 INFO org.hibernate.tool.hbm2ddl.SchemaExport - schema
export complete
12:15:12,065 INFO
org.hibernate.connection.DriverManagerConnectionProvider - cleaning up
connection pool: jdbc:h2:./database
[WARNING] 6 errors occurred while performing <hbm2ddl>.
[ERROR] Error #1: org.h2.jdbc.JdbcSQLException: Bedingung
"FK4F0581A12889F7E4" nicht gefunden
Constraint "FK4F0581A12889F7E4" not found; SQL statement:
alter table Forum_Group drop constraint FK4F0581A12889F7E4 [90057-154]
[ERROR] Error #1: org.h2.jdbc.JdbcSQLException: Bedingung
"FK6A3E42F69F0F1759" nicht gefunden
Constraint "FK6A3E42F69F0F1759" not found; SQL statement:
alter table Group_Article drop constraint FK6A3E42F69F0F1759
[90057-154]
[ERROR] Error #1: org.h2.jdbc.JdbcSQLException: Syntax Fehler in SQL
Befehl "DROP TABLE GROUP[*] IF EXISTS "; erwartet "identifier"
Syntax error in SQL statement "DROP TABLE GROUP[*] IF EXISTS ";
expected "identifier"; SQL statement:
drop table Group if exists [42001-154]
[ERROR] Error #1: org.h2.jdbc.JdbcSQLException: Syntax Fehler in SQL
Befehl "CREATE TABLE GROUP[*] (ID BIGINT GENERATED BY DEFAULT AS
IDENTITY, TITLE VARCHAR(255), PRIMARY KEY (ID)) "; erwartet
"identifier"
Syntax error in SQL statement "CREATE TABLE GROUP[*] (ID BIGINT
GENERATED BY DEFAULT AS IDENTITY, TITLE VARCHAR(255), PRIMARY KEY
(ID)) "; expected "identifier"; SQL statement:
create table Group (id bigint generated by default as identity, title
varchar(255), primary key (id)) [42001-154]
[ERROR] Error #1: org.h2.jdbc.JdbcSQLException: Syntax Fehler in SQL
Befehl "ALTER TABLE FORUM_GROUP ADD CONSTRAINT FK4F0581A12889F7E4
FOREIGN KEY (GROUPS_ID) REFERENCES GROUP[*] "; erwartet "identifier"
Syntax error in SQL statement "ALTER TABLE FORUM_GROUP ADD CONSTRAINT
FK4F0581A12889F7E4 FOREIGN KEY (GROUPS_ID) REFERENCES GROUP[*] ";
expected "identifier"; SQL statement:
alter table Forum_Group add constraint FK4F0581A12889F7E4 foreign key
(groups_id) references Group [42001-154]
[ERROR] Error #1: org.h2.jdbc.JdbcSQLException: Syntax Fehler in SQL
Befehl "ALTER TABLE GROUP_ARTICLE ADD CONSTRAINT FK6A3E42F69F0F1759
FOREIGN KEY (GROUP_ID) REFERENCES GROUP[*] "; erwartet "identifier"
Syntax error in SQL statement "ALTER TABLE GROUP_ARTICLE ADD
CONSTRAINT FK6A3E42F69F0F1759 FOREIGN KEY (GROUP_ID) REFERENCES
GROUP[*] "; expected "identifier"; SQL statement:
alter table Group_Article add constraint FK6A3E42F69F0F1759 foreign
key (Group_id) references Group [42001-154]
[INFO]