-->
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.  [ 9 posts ] 
Author Message
 Post subject: SchemaExport Ignoring Cascade Constraints
PostPosted: Wed Sep 10, 2003 1:02 pm 
Newbie

Joined: Tue Sep 02, 2003 8:22 am
Posts: 19
Location: Chicago
I'm using the SchemaExportTask to generate my schema from the mapping docs, and it isn't putting the correct "ON DELETE CASCADE" into the constraints. It's not putting anything for the cascade information. The cascade attribute is set to delete in appropriate locations in the mapping document.

Is this a limitation with the SchemaExport utility? Is there a workaround?

I'm running Hibernate 2.0.2 and PostgreSQL 7.3.4.

Thanks for any responses.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 10, 2003 1:05 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
cascade is done in-memory, by the Hibernate session.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 10, 2003 2:36 pm 
Newbie

Joined: Tue Sep 02, 2003 8:22 am
Posts: 19
Location: Chicago
Thanks for the feedback. Wouldn't it be better to use the database's cascading constraints rather than managing it in memory?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 10, 2003 2:38 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
nope. we need to know exactly what got deleted, in order to keep the session state synchronized with the database state.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 10, 2003 2:49 pm 
Newbie

Joined: Tue Sep 02, 2003 8:22 am
Posts: 19
Location: Chicago
I can appreciate that. The only reason I ask is that I'm using dbunit to load/update sample data into the database and it's complaining about FK violations, so it's not a Hibernate problem.

Maybe a tool like dbunit but using Hibernate to load sample data for testing? I'd be willing to build it if there are other people interested.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 10, 2003 2:52 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Currently I'm working together with Ara Abrahamian to implement something like this.

Ara is working on getting the XML databinding stuff finished, and I have implemented a Session.replicate() method.

So in future, you should be able to completely reproduce an object graph in the database, starting from an XML document.


Top
 Profile  
 
 Post subject: Whats the state of this feature in Hibernate3?
PostPosted: Thu Jan 27, 2005 12:19 pm 
Newbie

Joined: Fri Aug 27, 2004 6:53 pm
Posts: 4
I am using Hibernate-3 beta_1 and using SchemeExportTask. The generated schema doesnt have the "on delete cacade".

Just want to know if this is going to be fixed in Hibernate 3? We have a workaround but just wanted to see there is anything in the pipeline for Hibernate3.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 27, 2005 2:58 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Use <key on-delete="cascade"/>


Top
 Profile  
 
 Post subject: problem with mapping when using on-delete="cascade"
PostPosted: Tue Feb 22, 2005 9:52 am 
Newbie

Joined: Fri Aug 27, 2004 6:53 pm
Posts: 4
Thanks Gavin.

The generated schema has the "on delete cascade" added for the foreign key constraint after I added the <key on-delete="cascade"/>.

But the problem is that I get the mapping exception [only inverse one-to-many associations may use on-delete="cascade"] Collection.java:215 when the session is being initialized.

Does the relationship has to have [inverse="true"] to get this working? Why is this restriction?

Thanks again.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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.