-->
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.  [ 1 post ] 
Author Message
 Post subject: Helpfulness of DDL generated by SchemaExport?
PostPosted: Tue Apr 12, 2005 1:06 pm 
Newbie

Joined: Tue Apr 12, 2005 10:46 am
Posts: 2
I try to build a new database from scratch in a two step process :
1)Generate DDL with SchemaExport based on a few *.hbm.xml files
2)Build the database based on the DDL from the previous step

However, the DDL generated cannot be run in step 2, as is quite obvious when you look into the generated file (some statements omitted for clarity):
____________
alter table many_to_many_relation_table drop constraint FKB8C019B364057B70;

drop table many_to_many_relation_table if exists;

create table many_to_many_relation_table .............................

alter table many_to_many_relation_table add constraint FKB8C019B364057B70 foreign key (aId) references tableX;

alter table many_to_many_relation_table add constraint FKB8C019B3C042B583 foreign key (bId) references tableY;
_____________

In the first statement, there is an alter table statement that refers to a table that does not (yet) exist in the scenario of creating a db from scratch. Consequently, I cannot find a way to generate the DB based on the DDL in my step 2 (executing a SQL statement at the time)

However, if I reconsider my strategy and do it all in ONE operation using SchemaExport it works fine. It seems there is quite some magic going on when "SchemaExporting" to the db. So there are two cases:
a)let schemaexport target the db directly
b)take the ddl generated by schemaexport and run it against the database

Why isn't case a) and b) equivalent?
As b) does not work, what is the point in exporting the DDL to console or file? debugging? information?

Furthermore, if the ALTER TABLE ..DROP CONSTRAINT had been omitted, it would have worked just fine. Why is those included (the tables involved are droppen anyway)?

Currently it looks I will have to reimplement a slightly different schemaexport ant task to support my scenario, which doesn't feel good.

Have anybody been down this road?


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

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.