Hi,
I am trying to offer the following two statements in an auxiliary database object during sqlCreateString() for creating a table with a foraeign key in a mysql database.
create table T_ATTR_SETS (C_MM_ID bigint not null, C_VALUE varchar(255), C_SET_NAME varchar(255) not null); alter table T_ATTR_SETS add index FK2A68DFB477160F21 (C_MM_ID), add constraint FK2A68DFB477160F21 foreign key (C_MM_ID) references MM (C_MM_ID);
This works if I do this with the mysql console but not with the auxiliare database object. Hibernate logging says the following. It is a mysql syntax error that is blamed. But the staement is exactly the same. What am I doing wrong?
[2008-04-03 19:22:07,730] [main] [INFO ] [org.hibernate.tool.hbm2ddl.SchemaExport] [Running hbm2ddl schema export]
[2008-04-03 19:22:07,730] [main] [DEBUG] [org.hibernate.tool.hbm2ddl.SchemaExport] [import file not found: /import.sql]
[2008-04-03 19:22:07,730] [main] [INFO ] [org.hibernate.tool.hbm2ddl.SchemaExport] [exporting generated schema to database]
[2008-04-03 19:22:07,731] [main] [DEBUG] [org.hibernate.tool.hbm2ddl.SchemaExport] [drop table T_ATTR_SETS]
[2008-04-03 19:22:07,735] [main] [DEBUG] [org.hibernate.tool.hbm2ddl.SchemaExport] [Unsuccessful: drop table T_ATTR_SETS]
[2008-04-03 19:22:07,735] [main] [DEBUG] [org.hibernate.tool.hbm2ddl.SchemaExport] [Unknown table 'T_ATTR_SETS']
[2008-04-03 19:22:07,736] [main] [DEBUG] [org.hibernate.tool.hbm2ddl.SchemaExport] [drop table if exists MM]
[2008-04-03 19:22:07,736] [main] [DEBUG] [org.hibernate.tool.hbm2ddl.SchemaExport] [create table MM (C_MM_ID bigint not null auto_increment, primary key (C_MM_ID))]
[2008-04-03 19:22:07,823] [main] [DEBUG] [org.hibernate.tool.hbm2ddl.SchemaExport] [create table T_ATTR_SETS (C_MM_ID bigint not null, C_VALUE varchar(255), C_SET_NAME varchar(255) not null); alter table T_ATTR_SETS add index FK2A68DFB477160F21 (C_MM_ID), add constraint FK2A68DFB477160F21 foreign key (C_MM_ID) references MM (C_MM_ID);]
[2008-04-03 19:22:07,824] [main] [ERROR] [org.hibernate.tool.hbm2ddl.SchemaExport] [Unsuccessful: create table T_ATTR_SETS (C_MM_ID bigint not null, C_VALUE varchar(255), C_SET_NAME varchar(255) not null); alter table T_ATTR_SETS add index FK2A68DFB477160F21 (C_MM_ID), add constraint FK2A68DFB477160F21 foreign key (C_MM_ID) references MM (C_MM_ID);]
[2008-04-03 19:22:07,824] [main] [ERROR] [org.hibernate.tool.hbm2ddl.SchemaExport] [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; alter table T_ATTR_SETS add index FK2A68DFB477160F21 (C_MM_ID), add constraint' at line 1]
Thanks very much for help.
|