You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Gary Jarrel <ga...@gmail.com> on 2006/06/30 03:24:49 UTC

My Laziness is Getting the Better of Me

Hey All

It's Friday, and I guess my thinking process has already switched into
weekend mode, but whats the best way to clear all records in a
relationship. I.e. the following objects

Slideshow -> (to may) -> Image      (join table in betwen)

Slideshow.getImages() returns a list of images, how can I easily clear
this list, cause the good old iterate over the list and remove using
slideshow.removeFromImages(Image)  doesn't seem to work as the list
decreases hence sending the cursor off.

Sorry if the question is too obvious. :)

- garyj

Re: My Laziness is Getting the Better of Me

Posted by Marcin Skladaniec <ma...@ish.com.au>.
Hey !
Read http://objectstyle.org/cayenne/lists/cayenne-user/2006/06/0106.html
It describes how to remove objects without using removeFrom ;)

Cheers
Marcin

On 30/06/2006, at 11:24 AM, Gary Jarrel wrote:

> Hey All
>
> It's Friday, and I guess my thinking process has already switched into
> weekend mode, but whats the best way to clear all records in a
> relationship. I.e. the following objects
>
> Slideshow -> (to may) -> Image      (join table in betwen)
>
> Slideshow.getImages() returns a list of images, how can I easily clear
> this list, cause the good old iterate over the list and remove using
> slideshow.removeFromImages(Image)  doesn't seem to work as the list
> decreases hence sending the cursor off.
>
> Sorry if the question is too obvious. :)
>
> - garyj

-------------------------->
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001   fax +61 2 9550 4001



RE: My Laziness is Getting the Better of Me

Posted by "Gentry, Michael (Contractor)" <mi...@fanniemae.com>.
Yes, which is what I thought you wanted.  So, you have something like:

Slideshow <->> SlideshowToImages <<-> Image

Correct?  If so, you can essentially do the same thing:

dataContext.deleteObjects(slideshow.getSlideshowToImages());

Just make sure you don't cascade delete your images from the
many-to-many join.

/dev/mrg


-----Original Message-----
From: Gary Jarrel [mailto:garyjarrel@gmail.com] 
Sent: Thursday, June 29, 2006 11:37 PM
To: cayenne-user@incubator.apache.org
Subject: Re: My Laziness is Getting the Better of Me


But wouldn't the call to
dataContext.deleteObjects(slideshow.getImages()); actually delete the
image records from the image table (upon commit). All I'm trying to do
is clear the relationship table, because any given image form part of
any number of slideshows. Hence I don't want to delete the actual
images just the link (record in join table) between Slideshow & Image

- garyj

PS. Australia is just too far away from the world, hence Friday here :)

On 6/30/06, Michael Gentry <bl...@gmail.com> wrote:
> http://www.objectstyle.org/confluence/display/CAYDOC/Deleting+Objects
>
>
> So, I think:
>
> dataContext.deleteObjects(slideshow.getImages());
>
> might do the trick for you.
>
> /dev/mrg
>
> PS. It isn't Friday here yet ...
> PPS. Don't forget to do a dataContext.commitChanges(), too.
>
>
> On 6/29/06, Gary Jarrel <ga...@gmail.com> wrote:
> > Hey All
> >
> > It's Friday, and I guess my thinking process has already switched
into
> > weekend mode, but whats the best way to clear all records in a
> > relationship. I.e. the following objects
> >
> > Slideshow -> (to may) -> Image      (join table in betwen)
> >
> > Slideshow.getImages() returns a list of images, how can I easily
clear
> > this list, cause the good old iterate over the list and remove using
> > slideshow.removeFromImages(Image)  doesn't seem to work as the list
> > decreases hence sending the cursor off.
> >
> > Sorry if the question is too obvious. :)
> >
> > - garyj
> >
>

Re: My Laziness is Getting the Better of Me

Posted by Gary Jarrel <ga...@gmail.com>.
But wouldn't the call to
dataContext.deleteObjects(slideshow.getImages()); actually delete the
image records from the image table (upon commit). All I'm trying to do
is clear the relationship table, because any given image form part of
any number of slideshows. Hence I don't want to delete the actual
images just the link (record in join table) between Slideshow & Image

- garyj

PS. Australia is just too far away from the world, hence Friday here :)

On 6/30/06, Michael Gentry <bl...@gmail.com> wrote:
> http://www.objectstyle.org/confluence/display/CAYDOC/Deleting+Objects
>
>
> So, I think:
>
> dataContext.deleteObjects(slideshow.getImages());
>
> might do the trick for you.
>
> /dev/mrg
>
> PS. It isn't Friday here yet ...
> PPS. Don't forget to do a dataContext.commitChanges(), too.
>
>
> On 6/29/06, Gary Jarrel <ga...@gmail.com> wrote:
> > Hey All
> >
> > It's Friday, and I guess my thinking process has already switched into
> > weekend mode, but whats the best way to clear all records in a
> > relationship. I.e. the following objects
> >
> > Slideshow -> (to may) -> Image      (join table in betwen)
> >
> > Slideshow.getImages() returns a list of images, how can I easily clear
> > this list, cause the good old iterate over the list and remove using
> > slideshow.removeFromImages(Image)  doesn't seem to work as the list
> > decreases hence sending the cursor off.
> >
> > Sorry if the question is too obvious. :)
> >
> > - garyj
> >
>

Re: My Laziness is Getting the Better of Me

Posted by Michael Gentry <bl...@gmail.com>.
http://www.objectstyle.org/confluence/display/CAYDOC/Deleting+Objects


So, I think:

dataContext.deleteObjects(slideshow.getImages());

might do the trick for you.

/dev/mrg

PS. It isn't Friday here yet ...
PPS. Don't forget to do a dataContext.commitChanges(), too.


On 6/29/06, Gary Jarrel <ga...@gmail.com> wrote:
> Hey All
>
> It's Friday, and I guess my thinking process has already switched into
> weekend mode, but whats the best way to clear all records in a
> relationship. I.e. the following objects
>
> Slideshow -> (to may) -> Image      (join table in betwen)
>
> Slideshow.getImages() returns a list of images, how can I easily clear
> this list, cause the good old iterate over the list and remove using
> slideshow.removeFromImages(Image)  doesn't seem to work as the list
> decreases hence sending the cursor off.
>
> Sorry if the question is too obvious. :)
>
> - garyj
>