-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: schemaexport produces incompatible SQL for MySQL 4.1.9
PostPosted: Fri Feb 04, 2005 6:04 am 
Newbie

Joined: Fri Feb 04, 2005 5:36 am
Posts: 4
Hibernate version: 2.1.8

Name and version of the database you are using: MySQL 4.1.9

Typical schemaexport SQL:

alter table XXXX drop foreign key YYY;
...
drop table XXXX if exists;
...
create table XXXX ....

In 2.1.6 schemaexport didn't create the alter table statements. Now it does. If schemaexport is run against an empty database the attempt to alter a table that does not exist unsurprisingly causes a "table does not exist" error.

Have I missed a new configuration option?

Rych


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 04, 2005 6:23 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Use MySQLMyISAMDialect.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 04, 2005 6:25 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Oh, oops, that is HB3.


Just ignore the extra alter tables. They don't hurt. SchemaExport is designed to not stop when a failure occurs.

(Otherwise, you can create a custom dialect for MyISAM, just like in HB3.)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 04, 2005 6:50 am 
Newbie

Joined: Fri Feb 04, 2005 5:36 am
Posts: 4
I can, of course, manually edit the generated SQL to delete the alter statements but that kind of blows the automatic build process we have ;-)

Rych


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 04, 2005 6:51 am 
Newbie

Joined: Fri Feb 04, 2005 5:36 am
Posts: 4
Oh, and I'm using the InnoDB engine too....


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 04, 2005 6:53 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Then the alter table statements should be correct.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 04, 2005 8:11 am 
Newbie

Joined: Fri Feb 04, 2005 5:36 am
Posts: 4
Syntactically they are but MySQL/InnoDB complains if you try to "alter table .. drop foreign key..." on a table that does not exist. There isn't an equivalent "if exists" statement extension that can be added in the same way as "drop table ..." uses it. The error reported by MySQL seems reasonable to me. I have no knowledge of whether other database engines permit you to alter tables that don't exist.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 11, 2005 3:17 am 
Newbie

Joined: Sun Mar 06, 2005 10:08 pm
Posts: 3
On the same topic, I'm having trouble getting SchemaExport to create InnoDB tables, due to the addition of the "alter table" & "drop table" statements.

The method suggested in the FAQ (setting delim = "type=InnoDB;") doesn't work anymore. Output such as the following is generated:
Code:
alter table ... drop foreign key ... type=InnoDB;
drop table if exists ... type=InnoDB;
alter table ... add index ... (...), add constraint ... foreign key (...) references xxx (id) type=InnoDB;

This is broken syntax.

Apart from configuring the MySQL server to create all tables as InnoDB, is there any other workaround to creating InnoDB tables for the Hibernate entities?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.