@CascadeOnDelete and DDL generation on PostgreSQL [message #880125] |
Fri, 01 June 2012 09:27  |
Eclipse User |
|
|
|
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 #880245 is a reply to message #880189] |
Fri, 01 June 2012 13:42   |
Eclipse User |
|
|
|
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.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03621 seconds