db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <de...@segel.com>
Subject RE: Delete with cascade...
Date Thu, 22 Oct 2009 14:25:39 GMT

> -----Original Message-----
> From: Preben Mikael Bohn [mailto:preben@chin.dk]
> Sent: Thursday, October 22, 2009 7:18 AM
> To: Derby Discussion
> Subject: Re: Delete with cascade...
> The problem though is that I don't know the structure of the tables
> and I need to do a batch delete of several tables. I could of course
> go through each of the tables and manually find dependent tables but
> since I have to do this over and over again during development where
> the table structure changes significantly (automatically generated by
> Hibernate) this is really not an option...
> On the other hand I could go over all the tables and try to delete
> them in a loop until all data are deleted (although some delete
> statements would still fail)... That would probably do the trick...
> :-)
> Best regards Preben

First, don't use Hibernate. Sorry, but from practice a well written DAO will
be better performance-wise. Maybe look at JPA?

Second, remember that meta-data is your friend. 
You don't know much about your table structures, but Derby, the relational
database engine does.

You should be able to query and find these constraints. Then you can
programmatically determine which tables to delete records from and in which

Remember that meta data is your friend.
Oh wait, I already said that. But really, it is. Even if you use hibernate,
the logic to walk through the metadata won't change even if the underlying
tables do.



View raw message