Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » @CascadeOnDelete and DDL generation on PostgreSQL
@CascadeOnDelete and DDL generation on PostgreSQL [message #880125] Fri, 01 June 2012 13:27 Go to next message
Paul Kofon is currently offline Paul KofonFriend
Messages: 7
Registered: July 2010
Junior Member
I have the following mapping:

@OneToMany(mappedBy="glAccountType", orphanRemoval=true, cascade={CascadeType.ALL})
@CascadeOnDelete
private List<GlAccountClass> glAccountClasses;


When the DDL is generated, the generated constraint does not include the cascade deletion option, as expected. I'm using PostgreSQL 9.0.3. What I get is simply:

ALTER TABLE glaccountclass ADD CONSTRAINT fk_glaccountclass_type_id FOREIGN KEY (type_id) REFERENCES glaccounttype (id);

The ON DELETE CASCADE isn't included. I could go and add this constraint manually afterwards if I had only a few of these relationships where I want database deletes to be cascaded. But there are lots of them and I'd like EclipseLink to do it automatically.

Is there something I'm doing wrong? Any help would be appreciated.

Paul





Re: @CascadeOnDelete and DDL generation on PostgreSQL [message #880189 is a reply to message #880125] Fri, 01 June 2012 15:33 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
If you are not using a legacy system, why not just rely on JPA's cascade remove to delete the referenced object?

The design docs for CascadeOnDelete state it should be added to the DDL and it is in the latest code. Please turn on logging to finest and post the portion that shows EclipseLink initially connecting to the database - this will have the EclipseLink version and the databasePlatform instance it is using to connect, and can help determine if the wrong DB platform class is being used somehow.

Best Regards,
Chris
Re: @CascadeOnDelete and DDL generation on PostgreSQL [message #880245 is a reply to message #880189] Fri, 01 June 2012 17:42 Go to previous messageGo to next message
Paul Kofon is currently offline Paul KofonFriend
Messages: 7
Registered: July 2010
Junior Member
Hi Chris,

I actually have logging set to FINE and here's part of the log:

__________________________________________________________________________________
[EL Info]: 2012-06-01 18:26:07.375--ServerSession(27401907)--Thread(Thread[main,5,main])--EclipseLink, version: Eclipse Persistence Services - 2.3.2.v20111125-r10461
[EL Config]: 2012-06-01 18:26:07.406--ServerSession(27401907)--Connection(1528901)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
platform=>PostgreSQLPlatform
user name=> "postgres"
datasource URL=> "jdbc:postgresql://localhost:5432/jpa-quickstart"
))
[EL Config]: 2012-06-01 18:26:07.906--ServerSession(27401907)--Connection(29437671)--Thread(Thread[main,5,main])--Connected: jdbc:postgresql://localhost:5432/jpa-quickstart
User: postgres
Database: PostgreSQL Version: 9.0.3
Driver: PostgreSQL Native Driver Version: PostgreSQL 9.0 JDBC4 (build 801)

__________________________________________________________________________________

Yes, I intend to depend on JPA's cascade remove to delete the referenced object(s). However, I want the dependent rows to be removed from the database when the parent object is removed/deleted - that's why I need ON DELETE CASCADE.


Paul.
Re: @CascadeOnDelete and DDL generation on PostgreSQL [message #881932 is a reply to message #880245] Tue, 05 June 2012 14:13 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Can you include your complete mappings for both the source and target class and the DDL generated.

Also, ensure that you have recompiled/deployed your code after adding the @CascadeOnDelete annotation.


James : Wiki : Book : Blog : Twitter
Previous Topic:Changes from EntityListeners not propagated in commit
Next Topic:Update Call stored procedure parameter name length issue
Goto Forum:
  


Current Time: Wed Apr 24 13:46:08 GMT 2024

Powered by FUDForum. Page generated in 0.03384 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top