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
Saving a related model in constructor
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
  5 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
 
Subbu  
View profile  
 More options Dec 30 2011, 1:33 am
From: Subbu <subramani.athiku...@gmail.com>
Date: Thu, 29 Dec 2011 22:33:22 -0800 (PST)
Local: Fri, Dec 30 2011 1:33 am
Subject: Saving a related model in constructor

How can I save a related model within a constructor. For example:

public class Magazine extends Model {
  public Magazine() {
    new Subscription(this, user); // automatically make the owner subscribe
to the magazine
  }

}

public class Subscription extends Model {
  public Subscription(Magazine magazine, User user) {
    this.magazine = magazine;
    this.user = user;
  }

}

Magazine m = new Magazine();
======

When I create a new Magazine object and save it, it doesn't save the
Subscription model. Is there anything I am doing wrong here?


 
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.
Pascal Voitot Dev  
View profile  
 More options Dec 30 2011, 5:45 am
From: Pascal Voitot Dev <pascal.voitot....@gmail.com>
Date: Fri, 30 Dec 2011 11:45:18 +0100
Local: Fri, Dec 30 2011 5:45 am
Subject: Re: [play-framework] Saving a related model in constructor

First impression:
You're not saving the subscription when you save the magazine (or there is
a cascade I don't know)

Pascal

On Fri, Dec 30, 2011 at 7:33 AM, Subbu <subramani.athiku...@gmail.com>wrote:


 
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.
Subbu  
View profile  
 More options Dec 30 2011, 7:04 am
From: Subbu <subramani.athiku...@gmail.com>
Date: Fri, 30 Dec 2011 04:04:03 -0800 (PST)
Local: Fri, Dec 30 2011 7:04 am
Subject: Re: [play-framework] Saving a related model in constructor

When I save the parent model i.e Magazine, does the child get saved too?


 
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.
Subbu  
View profile  
 More options Dec 30 2011, 7:06 am
From: Subbu <subramani.athiku...@gmail.com>
Date: Fri, 30 Dec 2011 04:06:03 -0800 (PST)
Local: Fri, Dec 30 2011 7:06 am
Subject: Re: [play-framework] Saving a related model in constructor

Sorry, I meant: When I save the parent model i.e Magazine, shouldn't the
child get saved too?


 
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.
Pascal Voitot Dev  
View profile  
 More options Dec 30 2011, 7:24 am
From: Pascal Voitot Dev <pascal.voitot....@gmail.com>
Date: Fri, 30 Dec 2011 13:24:57 +0100
Local: Fri, Dec 30 2011 7:24 am
Subject: Re: [play-framework] Saving a related model in constructor

AFAIK, it depends on how you wrote your model, of the cascade type...

On Fri, Dec 30, 2011 at 1:06 PM, Subbu <subramani.athiku...@gmail.com>wrote:


 
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 »