Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Generate "on delete cascade" in DDL?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Stefan  
View profile  
 More options Nov 12 2012, 1:19 pm
From: Stefan <stefan.at....@googlemail.com>
Date: Mon, 12 Nov 2012 10:19:51 -0800 (PST)
Local: Mon, Nov 12 2012 1:19 pm
Subject: Generate "on delete cascade" in DDL?

Hello all,

I am modelling the following:
One NewsArticle has multiple Comments, each Comment belongs to exactly one
NewsArticle.
In SQL formulation: There is a foreign key from the Comment table to the
primary key in the NewsArticle table.

I successfully modelled this using Ebean (please see code below), but I am
yet missing one thing: When a NewsArticle is deleted, all associated
Comments shall be deleted. In SQL this would be "on delete cascade". How do
I get Ebean to generate "on delete cascade" in DDL? (jdbc mysql). Currently
Ebean generates "on delete restrict" instead of the intended "on delete
cascade".

My code as of now is:

*NewsArticle:*

* Comment:*

> @Entity
> public class Comment extends Model {

>     @OneToOne(cascade=CascadeType.REMOVE)
>     @Column(nullable=false)
>     public NewsArticle news;

>     @Id
>     public Integer comment_id;

>     @Column(nullable=false)
>     public String text;
> }

This code generates the tables and the foreign key constraint for the
Comments without any problem, but it generates "on delete restrict" instead
of "on update cascade"? ): How to tell Ebean to generate "on delete
cascade"?

Thanks for any hint :-)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Roper  
View profile  
 More options Nov 12 2012, 7:00 pm
From: James Roper <jrop...@gmail.com>
Date: Mon, 12 Nov 2012 16:00:15 -0800 (PST)
Local: Mon, Nov 12 2012 7:00 pm
Subject: Re: Generate "on delete cascade" in DDL?

Well, ebean should do the cascading deletes for you manually, that's why it
doesn't generate the ddl.  But, the ddl generation is just a temporary
thing for helping you get started quickly in a project.  Once it no longer
satisfies your needs, you should maintain it manually, at that point Play
won't generate it for you anymore.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Roper  
View profile  
 More options Nov 12 2012, 7:01 pm
From: James Roper <jrop...@gmail.com>
Date: Mon, 12 Nov 2012 16:01:11 -0800 (PST)
Local: Mon, Nov 12 2012 7:01 pm
Subject: Re: Generate "on delete cascade" in DDL?

Sorry, I was in the wrong forum, thought this was the Play forum :(

I need to find that on switch for my brain...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stefan  
View profile  
 More options Nov 13 2012, 2:40 pm
From: Stefan <stefan.at....@googlemail.com>
Date: Tue, 13 Nov 2012 11:40:22 -0800 (PST)
Local: Tues, Nov 13 2012 2:40 pm
Subject: Re: Generate "on delete cascade" in DDL?

I see nothing wrong on your post ;-)
And thanks for your information, still have to test this, but sounds good
:-)

Am Dienstag, 13. November 2012 01:01:11 UTC+1 schrieb James Roper:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »