Re: setter for toMany in generated classes
It is https://github.com/apache/cayenne/pull/80
Am 22.12.2015 um 08:25 schrieb Andrus Adamchik:
>> Is this ready for a pull request?
>> https://github.com/jotpe/cayenne/commits/master
>
> Go for it.
>
>
>> On Dec 21, 2015, at 10:57 PM, Johannes wrote:
>>
>> Thank you.
>>
>> I commited 4 test classes. The main part is in
>> org.apache.cayenne.CayenneDataObjectSetToManyListTest
>>
>> The other 3 classes, just make sure there is no problem (exception) with
>> another relation collection type.
>>
>> 'mvn test' runs cayenne-server without any error.
>> There are no new checkstyle warnings.
>>
>> Is this ready for a pull request?
>> https://github.com/jotpe/cayenne/commits/master
>>
>> Johannes
>>
>>
>>
>> Am 15.12.2015 um 07:58 schrieb Andrus Adamchik:
>>> We have a few such test entities:
>>>
>>> 1. Map: cayenne-map-to-many.xml (CayenneProjects.MAP_TO_MANY_PROJECT)
>>> 2. Set: cayenne-relationships-set-to-many.xml
>>> (CayenneProjects.RELATIONSHIPS_SET_TO_MANY_PROJECT)
>>>
>>> Since those are in different projects, you will need to create separate
>>> test classes for them.
>>>
>>> Andrus
>>>
>>>
On Dec 13, 2015, at 2:21 PM, Johannes wrote:
Currently I am writing the unit tests for the new method.
Most test cases are done with following class introduction (copied from
another test class in that package):
@UseServerRuntime(CayenneProjects.TESTMAP_PROJECT)
public class CayenneDataObjectSetToMany extends ServerCase {
@Inject
private ServerRuntime runtime;
@Inject
private ObjectContext context;
@Inject
private DBHelper dbHelper;
protected TableHelper tArtist;
protected TableHelper tPainting;
.
Calling artist.getPaintingArray() returns an ArrayList, which was fine
yet. Now I need to configure my test environment to return different
collection types (collection, list, map and set).
What is the best way to achieve that?
Best regards
Johannes
Am 07.12.2015 um 07:33 schrieb Andrus Adamchik:
> Thanks for the new version. Looks good to me. Let's maybe write some unit
> tests and create a new pull request.
>
> Andrus
>
>> On Dec 7, 2015, at 1:07 AM, Johannes wrote:
>>
>> Sure, here is a tidy commit:
>> https://github.com/apache/cayenne/commit/1358dad4e3ae2cf2735aa223b869e4b85f18508e
>>
>> Didn't know how to manipulate commits afterwards. I closed the pull
>> request and made my clean commit on a fresh reforked master version.
>>
>> Best Regards. Johannes
>>
>> Am 06.12.2015 um 10:05 schrieb Aristedes Maniatis:
>>> Great. Do you want to tidy up the commits on your pull request.
>>>
>>> https://github.com/apache/cayenne/pull/61/commits
>>>
>>> Ari
>>>
>>> On 6/12/2015 2:19am, Johannes wrote:
Dear list,
I want to bring back my idea from February into discussion. It was
about
introducing a setToManyTarget Method in the CayenneDataObject, but it
was not finished (mail archive:
http://mail-archives.apache.org/mod_mbox/cayenne-dev/201501.mbox/%3C0DBA750D-A847-4CC1-8EAC-9DCFB5A0FECA%
40objectstyle.org%3E )
My last action was, implementing Andrus advice to retrieve old
DataObjects, which can be deleted manually:
// sync...
List removed =
o.setToManyTarget(Artist.PAINTINGS.getName(), newPaintings,
true);
// delete ... or not
// o.getObjectContext().deleteObjects(removed);
This was implemented immediatly by myself with following commit, but I
forgot to mention it on the list:
It was implemented in
https://github.com/jotpe/cayenne/commit/b930886a9ab24fa8b82a7e8efeaf6d2437bd5d96
Best Regards.
Johannes
>>>
>>
>>
>>
signature.asc
Description: OpenPGP digital signature
Re: setter for toMany in generated classes
> Is this ready for a pull request?
> https://github.com/jotpe/cayenne/commits/master
Go for it.
> On Dec 21, 2015, at 10:57 PM, Johannes wrote:
>
> Thank you.
>
> I commited 4 test classes. The main part is in
> org.apache.cayenne.CayenneDataObjectSetToManyListTest
>
> The other 3 classes, just make sure there is no problem (exception) with
> another relation collection type.
>
> 'mvn test' runs cayenne-server without any error.
> There are no new checkstyle warnings.
>
> Is this ready for a pull request?
> https://github.com/jotpe/cayenne/commits/master
>
> Johannes
>
>
>
> Am 15.12.2015 um 07:58 schrieb Andrus Adamchik:
>> We have a few such test entities:
>>
>> 1. Map: cayenne-map-to-many.xml (CayenneProjects.MAP_TO_MANY_PROJECT)
>> 2. Set: cayenne-relationships-set-to-many.xml
>> (CayenneProjects.RELATIONSHIPS_SET_TO_MANY_PROJECT)
>>
>> Since those are in different projects, you will need to create separate test
>> classes for them.
>>
>> Andrus
>>
>>
>>> On Dec 13, 2015, at 2:21 PM, Johannes wrote:
>>>
>>> Currently I am writing the unit tests for the new method.
>>>
>>> Most test cases are done with following class introduction (copied from
>>> another test class in that package):
>>>
>>> @UseServerRuntime(CayenneProjects.TESTMAP_PROJECT)
>>> public class CayenneDataObjectSetToMany extends ServerCase {
>>>
>>> @Inject
>>> private ServerRuntime runtime;
>>>
>>> @Inject
>>> private ObjectContext context;
>>>
>>> @Inject
>>> private DBHelper dbHelper;
>>>
>>> protected TableHelper tArtist;
>>> protected TableHelper tPainting;
>>> .
>>>
>>> Calling artist.getPaintingArray() returns an ArrayList, which was fine
>>> yet. Now I need to configure my test environment to return different
>>> collection types (collection, list, map and set).
>>>
>>> What is the best way to achieve that?
>>>
>>> Best regards
>>> Johannes
>>>
>>> Am 07.12.2015 um 07:33 schrieb Andrus Adamchik:
Thanks for the new version. Looks good to me. Let's maybe write some unit
tests and create a new pull request.
Andrus
> On Dec 7, 2015, at 1:07 AM, Johannes wrote:
>
> Sure, here is a tidy commit:
> https://github.com/apache/cayenne/commit/1358dad4e3ae2cf2735aa223b869e4b85f18508e
>
> Didn't know how to manipulate commits afterwards. I closed the pull
> request and made my clean commit on a fresh reforked master version.
>
> Best Regards. Johannes
>
> Am 06.12.2015 um 10:05 schrieb Aristedes Maniatis:
>> Great. Do you want to tidy up the commits on your pull request.
>>
>> https://github.com/apache/cayenne/pull/61/commits
>>
>> Ari
>>
>> On 6/12/2015 2:19am, Johannes wrote:
>>> Dear list,
>>>
>>> I want to bring back my idea from February into discussion. It was about
>>> introducing a setToManyTarget Method in the CayenneDataObject, but it
>>> was not finished (mail archive:
>>> http://mail-archives.apache.org/mod_mbox/cayenne-dev/201501.mbox/%3C0DBA750D-A847-4CC1-8EAC-9DCFB5A0FECA%
>>> 40objectstyle.org%3E )
>>>
>>>
>>> My last action was, implementing Andrus advice to retrieve old
>>> DataObjects, which can be deleted manually:
>>>
>>> // sync...
>>> List removed =
>>> o.setToManyTarget(Artist.PAINTINGS.getName(), newPaintings,
>>> true);
>>>
>>> // delete ... or not
>>> // o.getObjectContext().deleteObjects(removed);
>>>
>>>
>>> This was implemented immediatly by myself with following commit, but I
>>> forgot to mention it on the list:
>>> It was implemented in
>>> https://github.com/jotpe/cayenne/commit/b930886a9ab24fa8b82a7e8efeaf6d2437bd5d96
>>>
>>>
>>> Best Regards.
>>> Johannes
>>>
>>
>
>
>>>
>
Re: setter for toMany in generated classes
Thank you.
I commited 4 test classes. The main part is in
org.apache.cayenne.CayenneDataObjectSetToManyListTest
The other 3 classes, just make sure there is no problem (exception) with
another relation collection type.
'mvn test' runs cayenne-server without any error.
There are no new checkstyle warnings.
Is this ready for a pull request?
https://github.com/jotpe/cayenne/commits/master
Johannes
Am 15.12.2015 um 07:58 schrieb Andrus Adamchik:
> We have a few such test entities:
>
> 1. Map: cayenne-map-to-many.xml (CayenneProjects.MAP_TO_MANY_PROJECT)
> 2. Set: cayenne-relationships-set-to-many.xml
> (CayenneProjects.RELATIONSHIPS_SET_TO_MANY_PROJECT)
>
> Since those are in different projects, you will need to create separate test
> classes for them.
>
> Andrus
>
>
>> On Dec 13, 2015, at 2:21 PM, Johannes wrote:
>>
>> Currently I am writing the unit tests for the new method.
>>
>> Most test cases are done with following class introduction (copied from
>> another test class in that package):
>>
>> @UseServerRuntime(CayenneProjects.TESTMAP_PROJECT)
>> public class CayenneDataObjectSetToMany extends ServerCase {
>>
>> @Inject
>> private ServerRuntime runtime;
>>
>> @Inject
>> private ObjectContext context;
>>
>> @Inject
>> private DBHelper dbHelper;
>>
>> protected TableHelper tArtist;
>> protected TableHelper tPainting;
>> .
>>
>> Calling artist.getPaintingArray() returns an ArrayList, which was fine
>> yet. Now I need to configure my test environment to return different
>> collection types (collection, list, map and set).
>>
>> What is the best way to achieve that?
>>
>> Best regards
>> Johannes
>>
>> Am 07.12.2015 um 07:33 schrieb Andrus Adamchik:
>>> Thanks for the new version. Looks good to me. Let's maybe write some unit
>>> tests and create a new pull request.
>>>
>>> Andrus
>>>
On Dec 7, 2015, at 1:07 AM, Johannes wrote:
Sure, here is a tidy commit:
https://github.com/apache/cayenne/commit/1358dad4e3ae2cf2735aa223b869e4b85f18508e
Didn't know how to manipulate commits afterwards. I closed the pull
request and made my clean commit on a fresh reforked master version.
Best Regards. Johannes
Am 06.12.2015 um 10:05 schrieb Aristedes Maniatis:
> Great. Do you want to tidy up the commits on your pull request.
>
> https://github.com/apache/cayenne/pull/61/commits
>
> Ari
>
> On 6/12/2015 2:19am, Johannes wrote:
>> Dear list,
>>
>> I want to bring back my idea from February into discussion. It was about
>> introducing a setToManyTarget Method in the CayenneDataObject, but it
>> was not finished (mail archive:
>> http://mail-archives.apache.org/mod_mbox/cayenne-dev/201501.mbox/%3C0DBA750D-A847-4CC1-8EAC-9DCFB5A0FECA%
>> 40objectstyle.org%3E )
>>
>>
>> My last action was, implementing Andrus advice to retrieve old
>> DataObjects, which can be deleted manually:
>>
>> // sync...
>> List removed =
>> o.setToManyTarget(Artist.PAINTINGS.getName(), newPaintings,
>> true);
>>
>> // delete ... or not
>> // o.getObjectContext().deleteObjects(removed);
>>
>>
>> This was implemented immediatly by myself with following commit, but I
>> forgot to mention it on the list:
>> It was implemented in
>> https://github.com/jotpe/cayenne/commit/b930886a9ab24fa8b82a7e8efeaf6d2437bd5d96
>>
>>
>> Best Regards.
>> Johannes
>>
>
>>
signature.asc
Description: OpenPGP digital signature
Re: setter for toMany in generated classes
We have a few such test entities:
1. Map: cayenne-map-to-many.xml (CayenneProjects.MAP_TO_MANY_PROJECT)
2. Set: cayenne-relationships-set-to-many.xml
(CayenneProjects.RELATIONSHIPS_SET_TO_MANY_PROJECT)
Since those are in different projects, you will need to create separate test
classes for them.
Andrus
> On Dec 13, 2015, at 2:21 PM, Johannes wrote:
>
> Currently I am writing the unit tests for the new method.
>
> Most test cases are done with following class introduction (copied from
> another test class in that package):
>
> @UseServerRuntime(CayenneProjects.TESTMAP_PROJECT)
> public class CayenneDataObjectSetToMany extends ServerCase {
>
> @Inject
> private ServerRuntime runtime;
>
> @Inject
> private ObjectContext context;
>
> @Inject
> private DBHelper dbHelper;
>
> protected TableHelper tArtist;
> protected TableHelper tPainting;
> .
>
> Calling artist.getPaintingArray() returns an ArrayList, which was fine
> yet. Now I need to configure my test environment to return different
> collection types (collection, list, map and set).
>
> What is the best way to achieve that?
>
> Best regards
> Johannes
>
> Am 07.12.2015 um 07:33 schrieb Andrus Adamchik:
>> Thanks for the new version. Looks good to me. Let's maybe write some unit
>> tests and create a new pull request.
>>
>> Andrus
>>
>>> On Dec 7, 2015, at 1:07 AM, Johannes wrote:
>>>
>>> Sure, here is a tidy commit:
>>> https://github.com/apache/cayenne/commit/1358dad4e3ae2cf2735aa223b869e4b85f18508e
>>>
>>> Didn't know how to manipulate commits afterwards. I closed the pull
>>> request and made my clean commit on a fresh reforked master version.
>>>
>>> Best Regards. Johannes
>>>
>>> Am 06.12.2015 um 10:05 schrieb Aristedes Maniatis:
Great. Do you want to tidy up the commits on your pull request.
https://github.com/apache/cayenne/pull/61/commits
Ari
On 6/12/2015 2:19am, Johannes wrote:
> Dear list,
>
> I want to bring back my idea from February into discussion. It was about
> introducing a setToManyTarget Method in the CayenneDataObject, but it
> was not finished (mail archive:
> http://mail-archives.apache.org/mod_mbox/cayenne-dev/201501.mbox/%3C0DBA750D-A847-4CC1-8EAC-9DCFB5A0FECA%
> 40objectstyle.org%3E )
>
>
> My last action was, implementing Andrus advice to retrieve old
> DataObjects, which can be deleted manually:
>
> // sync...
> List removed =
> o.setToManyTarget(Artist.PAINTINGS.getName(), newPaintings,
> true);
>
> // delete ... or not
> // o.getObjectContext().deleteObjects(removed);
>
>
> This was implemented immediatly by myself with following commit, but I
> forgot to mention it on the list:
> It was implemented in
> https://github.com/jotpe/cayenne/commit/b930886a9ab24fa8b82a7e8efeaf6d2437bd5d96
>
>
> Best Regards.
> Johannes
>
>>>
>>>
>
Re: setter for toMany in generated classes
Currently I am writing the unit tests for the new method.
Most test cases are done with following class introduction (copied from
another test class in that package):
@UseServerRuntime(CayenneProjects.TESTMAP_PROJECT)
public class CayenneDataObjectSetToMany extends ServerCase {
@Inject
private ServerRuntime runtime;
@Inject
private ObjectContext context;
@Inject
private DBHelper dbHelper;
protected TableHelper tArtist;
protected TableHelper tPainting;
.
Calling artist.getPaintingArray() returns an ArrayList, which was fine
yet. Now I need to configure my test environment to return different
collection types (collection, list, map and set).
What is the best way to achieve that?
Best regards
Johannes
Am 07.12.2015 um 07:33 schrieb Andrus Adamchik:
> Thanks for the new version. Looks good to me. Let's maybe write some unit
> tests and create a new pull request.
>
> Andrus
>
>> On Dec 7, 2015, at 1:07 AM, Johannes wrote:
>>
>> Sure, here is a tidy commit:
>> https://github.com/apache/cayenne/commit/1358dad4e3ae2cf2735aa223b869e4b85f18508e
>>
>> Didn't know how to manipulate commits afterwards. I closed the pull
>> request and made my clean commit on a fresh reforked master version.
>>
>> Best Regards. Johannes
>>
>> Am 06.12.2015 um 10:05 schrieb Aristedes Maniatis:
>>> Great. Do you want to tidy up the commits on your pull request.
>>>
>>> https://github.com/apache/cayenne/pull/61/commits
>>>
>>> Ari
>>>
>>> On 6/12/2015 2:19am, Johannes wrote:
Dear list,
I want to bring back my idea from February into discussion. It was about
introducing a setToManyTarget Method in the CayenneDataObject, but it
was not finished (mail archive:
http://mail-archives.apache.org/mod_mbox/cayenne-dev/201501.mbox/%3C0DBA750D-A847-4CC1-8EAC-9DCFB5A0FECA%
40objectstyle.org%3E )
My last action was, implementing Andrus advice to retrieve old
DataObjects, which can be deleted manually:
// sync...
List removed =
o.setToManyTarget(Artist.PAINTINGS.getName(), newPaintings,
true);
// delete ... or not
// o.getObjectContext().deleteObjects(removed);
This was implemented immediatly by myself with following commit, but I
forgot to mention it on the list:
It was implemented in
https://github.com/jotpe/cayenne/commit/b930886a9ab24fa8b82a7e8efeaf6d2437bd5d96
Best Regards.
Johannes
>>>
>>
>>
signature.asc
Description: OpenPGP digital signature
Re: setter for toMany in generated classes
Hello Michael, yes, this was Andrus idea. I like it. Perhaps one other way to deal with deletions, is to return a collection of removed objects from the method, leaving it up to the caller to deal with them: // sync... List removed = o.setToManyTarget(Artist.PAINTINGS.getName(), newPaintings, true); // delete ... or not // o.getObjectContext().deleteObjects(removed); Am 07.12.2015 um 16:49 schrieb Michael Gentry: > Hi Johannes, > > Are you anticipating something like this if you want to actually delete > objects instead of just unlink them? > > dataContext.deleteObjects(cayenneDataObject.setToManyTarget(...)); > > Thanks, > > mrg > > > On Mon, Dec 7, 2015 at 1:33 AM, Andrus Adamchik > wrote: > >> Thanks for the new version. Looks good to me. Let's maybe write some unit >> tests and create a new pull request. >> >> Andrus >> >>> On Dec 7, 2015, at 1:07 AM, Johannes wrote: >>> >>> Sure, here is a tidy commit: >>> >> https://github.com/apache/cayenne/commit/1358dad4e3ae2cf2735aa223b869e4b85f18508e >>> >>> Didn't know how to manipulate commits afterwards. I closed the pull >>> request and made my clean commit on a fresh reforked master version. >>> >>> Best Regards. Johannes >>> >>> Am 06.12.2015 um 10:05 schrieb Aristedes Maniatis: Great. Do you want to tidy up the commits on your pull request. https://github.com/apache/cayenne/pull/61/commits Ari On 6/12/2015 2:19am, Johannes wrote: > Dear list, > > I want to bring back my idea from February into discussion. It was >> about > introducing a setToManyTarget Method in the CayenneDataObject, but it > was not finished (mail archive: > >> http://mail-archives.apache.org/mod_mbox/cayenne-dev/201501.mbox/%3C0DBA750D-A847-4CC1-8EAC-9DCFB5A0FECA% > 40objectstyle.org%3E ) > > > My last action was, implementing Andrus advice to retrieve old > DataObjects, which can be deleted manually: > > // sync... > List removed = > o.setToManyTarget(Artist.PAINTINGS.getName(), newPaintings, > true); > > // delete ... or not > // o.getObjectContext().deleteObjects(removed); > > > This was implemented immediatly by myself with following commit, but I > forgot to mention it on the list: > It was implemented in > >> https://github.com/jotpe/cayenne/commit/b930886a9ab24fa8b82a7e8efeaf6d2437bd5d96 > > > Best Regards. > Johannes > >>> >>> >> >> > signature.asc Description: OpenPGP digital signature
Re: setter for toMany in generated classes
Hi Johannes, Are you anticipating something like this if you want to actually delete objects instead of just unlink them? dataContext.deleteObjects(cayenneDataObject.setToManyTarget(...)); Thanks, mrg On Mon, Dec 7, 2015 at 1:33 AM, Andrus Adamchik wrote: > Thanks for the new version. Looks good to me. Let's maybe write some unit > tests and create a new pull request. > > Andrus > > > On Dec 7, 2015, at 1:07 AM, Johannes wrote: > > > > Sure, here is a tidy commit: > > > https://github.com/apache/cayenne/commit/1358dad4e3ae2cf2735aa223b869e4b85f18508e > > > > Didn't know how to manipulate commits afterwards. I closed the pull > > request and made my clean commit on a fresh reforked master version. > > > > Best Regards. Johannes > > > > Am 06.12.2015 um 10:05 schrieb Aristedes Maniatis: > >> Great. Do you want to tidy up the commits on your pull request. > >> > >> https://github.com/apache/cayenne/pull/61/commits > >> > >> Ari > >> > >> On 6/12/2015 2:19am, Johannes wrote: > >>> Dear list, > >>> > >>> I want to bring back my idea from February into discussion. It was > about > >>> introducing a setToManyTarget Method in the CayenneDataObject, but it > >>> was not finished (mail archive: > >>> > http://mail-archives.apache.org/mod_mbox/cayenne-dev/201501.mbox/%3C0DBA750D-A847-4CC1-8EAC-9DCFB5A0FECA% > >>> 40objectstyle.org%3E ) > >>> > >>> > >>> My last action was, implementing Andrus advice to retrieve old > >>> DataObjects, which can be deleted manually: > >>> > >>> // sync... > >>> List removed = > >>> o.setToManyTarget(Artist.PAINTINGS.getName(), newPaintings, > >>> true); > >>> > >>> // delete ... or not > >>> // o.getObjectContext().deleteObjects(removed); > >>> > >>> > >>> This was implemented immediatly by myself with following commit, but I > >>> forgot to mention it on the list: > >>> It was implemented in > >>> > https://github.com/jotpe/cayenne/commit/b930886a9ab24fa8b82a7e8efeaf6d2437bd5d96 > >>> > >>> > >>> Best Regards. > >>> Johannes > >>> > >> > > > > > >
Re: setter for toMany in generated classes
Thanks for the new version. Looks good to me. Let's maybe write some unit tests and create a new pull request. Andrus > On Dec 7, 2015, at 1:07 AM, Johannes wrote: > > Sure, here is a tidy commit: > https://github.com/apache/cayenne/commit/1358dad4e3ae2cf2735aa223b869e4b85f18508e > > Didn't know how to manipulate commits afterwards. I closed the pull > request and made my clean commit on a fresh reforked master version. > > Best Regards. Johannes > > Am 06.12.2015 um 10:05 schrieb Aristedes Maniatis: >> Great. Do you want to tidy up the commits on your pull request. >> >> https://github.com/apache/cayenne/pull/61/commits >> >> Ari >> >> On 6/12/2015 2:19am, Johannes wrote: >>> Dear list, >>> >>> I want to bring back my idea from February into discussion. It was about >>> introducing a setToManyTarget Method in the CayenneDataObject, but it >>> was not finished (mail archive: >>> http://mail-archives.apache.org/mod_mbox/cayenne-dev/201501.mbox/%3C0DBA750D-A847-4CC1-8EAC-9DCFB5A0FECA% >>> 40objectstyle.org%3E ) >>> >>> >>> My last action was, implementing Andrus advice to retrieve old >>> DataObjects, which can be deleted manually: >>> >>> // sync... >>> List removed = >>> o.setToManyTarget(Artist.PAINTINGS.getName(), newPaintings, >>> true); >>> >>> // delete ... or not >>> // o.getObjectContext().deleteObjects(removed); >>> >>> >>> This was implemented immediatly by myself with following commit, but I >>> forgot to mention it on the list: >>> It was implemented in >>> https://github.com/jotpe/cayenne/commit/b930886a9ab24fa8b82a7e8efeaf6d2437bd5d96 >>> >>> >>> Best Regards. >>> Johannes >>> >> > >
Re: setter for toMany in generated classes
Sure, here is a tidy commit: https://github.com/apache/cayenne/commit/1358dad4e3ae2cf2735aa223b869e4b85f18508e Didn't know how to manipulate commits afterwards. I closed the pull request and made my clean commit on a fresh reforked master version. Best Regards. Johannes Am 06.12.2015 um 10:05 schrieb Aristedes Maniatis: > Great. Do you want to tidy up the commits on your pull request. > > https://github.com/apache/cayenne/pull/61/commits > > Ari > > On 6/12/2015 2:19am, Johannes wrote: >> Dear list, >> >> I want to bring back my idea from February into discussion. It was about >> introducing a setToManyTarget Method in the CayenneDataObject, but it >> was not finished (mail archive: >> http://mail-archives.apache.org/mod_mbox/cayenne-dev/201501.mbox/%3C0DBA750D-A847-4CC1-8EAC-9DCFB5A0FECA% >> 40objectstyle.org%3E ) >> >> >> My last action was, implementing Andrus advice to retrieve old >> DataObjects, which can be deleted manually: >> >> // sync... >> List removed = >> o.setToManyTarget(Artist.PAINTINGS.getName(), newPaintings, >> true); >> >> // delete ... or not >> // o.getObjectContext().deleteObjects(removed); >> >> >> This was implemented immediatly by myself with following commit, but I >> forgot to mention it on the list: >> It was implemented in >> https://github.com/jotpe/cayenne/commit/b930886a9ab24fa8b82a7e8efeaf6d2437bd5d96 >> >> >> Best Regards. >> Johannes >> > signature.asc Description: OpenPGP digital signature
Re: setter for toMany in generated classes
Great. Do you want to tidy up the commits on your pull request. https://github.com/apache/cayenne/pull/61/commits Ari On 6/12/2015 2:19am, Johannes wrote: > Dear list, > > I want to bring back my idea from February into discussion. It was about > introducing a setToManyTarget Method in the CayenneDataObject, but it > was not finished (mail archive: > http://mail-archives.apache.org/mod_mbox/cayenne-dev/201501.mbox/%3C0DBA750D-A847-4CC1-8EAC-9DCFB5A0FECA% > 40objectstyle.org%3E ) > > > My last action was, implementing Andrus advice to retrieve old > DataObjects, which can be deleted manually: > > // sync... > List removed = > o.setToManyTarget(Artist.PAINTINGS.getName(), newPaintings, > true); > > // delete ... or not > // o.getObjectContext().deleteObjects(removed); > > > This was implemented immediatly by myself with following commit, but I > forgot to mention it on the list: > It was implemented in > https://github.com/jotpe/cayenne/commit/b930886a9ab24fa8b82a7e8efeaf6d2437bd5d96 > > > Best Regards. > Johannes > -- --> Aristedes Maniatis GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A
setter for toMany in generated classes
Dear list, I want to bring back my idea from February into discussion. It was about introducing a setToManyTarget Method in the CayenneDataObject, but it was not finished (mail archive: http://mail-archives.apache.org/mod_mbox/cayenne-dev/201501.mbox/%3C0DBA750D-A847-4CC1-8EAC-9DCFB5A0FECA% 40objectstyle.org%3E ) My last action was, implementing Andrus advice to retrieve old DataObjects, which can be deleted manually: // sync... List removed = o.setToManyTarget(Artist.PAINTINGS.getName(), newPaintings, true); // delete ... or not // o.getObjectContext().deleteObjects(removed); This was implemented immediatly by myself with following commit, but I forgot to mention it on the list: It was implemented in https://github.com/jotpe/cayenne/commit/b930886a9ab24fa8b82a7e8efeaf6d2437bd5d96 Best Regards. Johannes signature.asc Description: OpenPGP digital signature
Re: setter for toMany in generated classes
> On Jan 27, 2015, at 1:49 PM, Johannes wrote: > > What do you mean with sync? Synchronized method? I meant that we are "synchronizing" a relationship with our own collection. Andrus
Re: setter for toMany in generated classes
Looks better than a delete parameter. What do you mean with sync? Synchronized method? Regards Johannes Am 26.01.2015 um 22:23 schrieb Andrus Adamchik: > >> On Jan 26, 2015, at 1:47 PM, Johannes wrote: > >> My motivation for introducing the delete parameter was, that your are >> not able to the treat orphaned objects with a delete rule. Please >> correct me, if its wrong. The delete rule is called only, if you trigger >> .delete(). If you just remove your relationship: no entity will be >> deleted. I guess this is the deletion question Michael Gentry was >> talking about. > > Good point about delete rules. You are absolutely right and I stand > corrected. Perhaps one other way to deal with deletions, is to return a > collection of removed objects from the method, leaving it up to the caller to > deal with them: > > // sync... > List removed = > o.setToManyTarget(Artist.PAINTINGS.getName(), newPaintings, true); > > // delete ... or not > // o.getObjectContext().deleteObjects(removed); > > Andrus > > > > > signature.asc Description: OpenPGP digital signature
Re: setter for toMany in generated classes
> On Jan 26, 2015, at 1:47 PM, Johannes wrote: > My motivation for introducing the delete parameter was, that your are > not able to the treat orphaned objects with a delete rule. Please > correct me, if its wrong. The delete rule is called only, if you trigger > .delete(). If you just remove your relationship: no entity will be > deleted. I guess this is the deletion question Michael Gentry was > talking about. Good point about delete rules. You are absolutely right and I stand corrected. Perhaps one other way to deal with deletions, is to return a collection of removed objects from the method, leaving it up to the caller to deal with them: // sync... List removed = o.setToManyTarget(Artist.PAINTINGS.getName(), newPaintings, true); // delete ... or not // o.getObjectContext().deleteObjects(removed); Andrus
Re: setter for toMany in generated classes
I'm fine with activating the toMany-setter in subclasses manually.
My motivation for introducing the delete parameter was, that your are
not able to the treat orphaned objects with a delete rule. Please
correct me, if its wrong. The delete rule is called only, if you trigger
.delete(). If you just remove your relationship: no entity will be
deleted. I guess this is the deletion question Michael Gentry was
talking about.
Am 25.01.2015 um 13:13 schrieb Andrus Adamchik:
>
>> On Dec 27, 2014, at 6:07 PM, Johannes wrote:
>>
>> Hello, I moved the method to CayenneDataObject. I hope the documentation
>> is more meaningfull now.
>>
>> The superclass.vm contains for every set-able relationship two method
>> which calls the setter in CayenneDataObject. Two methods because a
>> default value for deletion.
>>
>> Would be happy if anybody could review it again at
>> https://github.com/jotpe/cayenne/commit/d7251014c9d5cb9396a83cd6e2f16e64af27e4b5
>>
>> Regards Johannes
>
> So we are talking about this pull request:
> https://github.com/apache/cayenne/pull/61 .
>
> A question to Cayenne committers and community ... Proposed implementation
> will require cleanup, optimization and very thorough testing. But aside from
> that, do we think a collection setter is universally useful to a point that
> all to-many relationships should expose it?
>
> Here is my feedback. I am ok with including a to-many collection "sync"
> operation in CayenneDataObject, but I am against placing it in default .vm
> template. This is based on the assumption that we are dealing with an
> occasionally, but not universally useful operation. So e.g. if a user decides
> he needs this op for Artist.paintings(..) collection, he would simply create
> a method in a subclass:
>
> Artist extends _Artist {
>
>void setPaintings(List ps) {
>setToManyTarget(_Artist.PAINTINGS, ps, true);
>}
> }
>
> An ability to extend template behavior with custom per-object code is exactly
> the reason we have sub/superclass separation.
>
> Also I am tentatively -1 on the delete option. I would generally handle it
> with a proper delete rule in the model.
>
> Thoughts?
> Andrus
>
>
signature.asc
Description: OpenPGP digital signature
Re: setter for toMany in generated classes
In a few of our projects I created a custom template that added a to-many
setter, but ours threw an exception if you called it on an already
populated relationship. This made sense for our domain, as we were doing
massive XML->Java (Cayenne objects) and wanted to be sure the
transformation tool we were using was not calling the setter multiple times
(which would indicate a problem in our mappings/etc). When I'm actually
managing the relationships, I tend to prefer doing the adds/removes/deletes
explicitly, but that's just my preference.
I know other times we've had to sync from an external data source which
required loading the Cayenne objects, loading the external data, and
figuring out what needed to be inserted/deleted. This always ended up
being more trouble that you'd think and perhaps having sync operation on
the to-many setter would've been helpful, but you still have the deletion
question to handle, too. I suppose this could be another parameter.
mrg
On Sun, Jan 25, 2015 at 7:13 AM, Andrus Adamchik
wrote:
>
> > On Dec 27, 2014, at 6:07 PM, Johannes wrote:
> >
> > Hello, I moved the method to CayenneDataObject. I hope the documentation
> > is more meaningfull now.
> >
> > The superclass.vm contains for every set-able relationship two method
> > which calls the setter in CayenneDataObject. Two methods because a
> > default value for deletion.
> >
> > Would be happy if anybody could review it again at
> >
> https://github.com/jotpe/cayenne/commit/d7251014c9d5cb9396a83cd6e2f16e64af27e4b5
> >
> > Regards Johannes
>
> So we are talking about this pull request:
> https://github.com/apache/cayenne/pull/61 .
>
> A question to Cayenne committers and community ... Proposed implementation
> will require cleanup, optimization and very thorough testing. But aside
> from that, do we think a collection setter is universally useful to a point
> that all to-many relationships should expose it?
>
> Here is my feedback. I am ok with including a to-many collection "sync"
> operation in CayenneDataObject, but I am against placing it in default .vm
> template. This is based on the assumption that we are dealing with an
> occasionally, but not universally useful operation. So e.g. if a user
> decides he needs this op for Artist.paintings(..) collection, he would
> simply create a method in a subclass:
>
> Artist extends _Artist {
>
>void setPaintings(List ps) {
>setToManyTarget(_Artist.PAINTINGS, ps, true);
>}
> }
>
> An ability to extend template behavior with custom per-object code is
> exactly the reason we have sub/superclass separation.
>
> Also I am tentatively -1 on the delete option. I would generally handle it
> with a proper delete rule in the model.
>
> Thoughts?
> Andrus
>
>
>
Re: setter for toMany in generated classes
I am also of the opinion that this should be a per-user customization
that someone can make rather than something that should be provided
out of the box. I don't think this should be part of Cayenne.
But since I'm not an active committer any more, I wasn't going to be
the first to say so.
On Sun, Jan 25, 2015 at 7:13 AM, Andrus Adamchik wrote:
>
>> On Dec 27, 2014, at 6:07 PM, Johannes wrote:
>>
>> Hello, I moved the method to CayenneDataObject. I hope the documentation
>> is more meaningfull now.
>>
>> The superclass.vm contains for every set-able relationship two method
>> which calls the setter in CayenneDataObject. Two methods because a
>> default value for deletion.
>>
>> Would be happy if anybody could review it again at
>> https://github.com/jotpe/cayenne/commit/d7251014c9d5cb9396a83cd6e2f16e64af27e4b5
>>
>> Regards Johannes
>
> So we are talking about this pull request:
> https://github.com/apache/cayenne/pull/61 .
>
> A question to Cayenne committers and community ... Proposed implementation
> will require cleanup, optimization and very thorough testing. But aside from
> that, do we think a collection setter is universally useful to a point that
> all to-many relationships should expose it?
>
> Here is my feedback. I am ok with including a to-many collection "sync"
> operation in CayenneDataObject, but I am against placing it in default .vm
> template. This is based on the assumption that we are dealing with an
> occasionally, but not universally useful operation. So e.g. if a user decides
> he needs this op for Artist.paintings(..) collection, he would simply create
> a method in a subclass:
>
> Artist extends _Artist {
>
>void setPaintings(List ps) {
>setToManyTarget(_Artist.PAINTINGS, ps, true);
>}
> }
>
> An ability to extend template behavior with custom per-object code is exactly
> the reason we have sub/superclass separation.
>
> Also I am tentatively -1 on the delete option. I would generally handle it
> with a proper delete rule in the model.
>
> Thoughts?
> Andrus
>
>
Re: setter for toMany in generated classes
> On Dec 27, 2014, at 6:07 PM, Johannes wrote:
>
> Hello, I moved the method to CayenneDataObject. I hope the documentation
> is more meaningfull now.
>
> The superclass.vm contains for every set-able relationship two method
> which calls the setter in CayenneDataObject. Two methods because a
> default value for deletion.
>
> Would be happy if anybody could review it again at
> https://github.com/jotpe/cayenne/commit/d7251014c9d5cb9396a83cd6e2f16e64af27e4b5
>
> Regards Johannes
So we are talking about this pull request:
https://github.com/apache/cayenne/pull/61 .
A question to Cayenne committers and community ... Proposed implementation will
require cleanup, optimization and very thorough testing. But aside from that,
do we think a collection setter is universally useful to a point that all
to-many relationships should expose it?
Here is my feedback. I am ok with including a to-many collection "sync"
operation in CayenneDataObject, but I am against placing it in default .vm
template. This is based on the assumption that we are dealing with an
occasionally, but not universally useful operation. So e.g. if a user decides
he needs this op for Artist.paintings(..) collection, he would simply create a
method in a subclass:
Artist extends _Artist {
void setPaintings(List ps) {
setToManyTarget(_Artist.PAINTINGS, ps, true);
}
}
An ability to extend template behavior with custom per-object code is exactly
the reason we have sub/superclass separation.
Also I am tentatively -1 on the delete option. I would generally handle it with
a proper delete rule in the model.
Thoughts?
Andrus
Re: setter for toMany in generated classes
Hello, I moved the method to CayenneDataObject. I hope the documentation
is more meaningfull now.
The superclass.vm contains for every set-able relationship two method
which calls the setter in CayenneDataObject. Two methods because a
default value for deletion.
Would be happy if anybody could review it again at
https://github.com/jotpe/cayenne/commit/d7251014c9d5cb9396a83cd6e2f16e64af27e4b5
Regards Johannes
Am 20.12.2014 um 01:01 schrieb Johannes:
> Hi Michael,
>
> thank for this scenario.
>
> My intention is to create a simple setter. A List or Set as Parameter is
> just a container for the complete amount of elements which should be set.
>
> The method works just on a copy of the List Parameter. When the input
> parameter is a persistet ToManyList, it will be downgraded to none
> persistent ArrayList.
>
> Calling A1.setB(C) should create
> A1 ->> B1, B2, B5, B7
>
>> Should it automatically try to reconcile all changes amongst all
> objects in
>> the object graph (removing objects from A1 and A2)
>
> No
>
>> Also, what should happen to B3? Should it be deleted or
>> orphaned?
>
> I didn't thought yet about orphaned elements. Good point.
> No doubt, the relationship to B3 has to be removed. Best would be to
> take care about the element as required by the deletion rule.
>
> I guess, I should write the method documentation more clearly.
>
> Regards Johannes
>
> Am 19.12.2014 um 15:11 schrieb Michael Gentry:
>> Hi Johannes,
>>
>> What you consider basic functionality can actually be not so basic.
>>
>> Consider this scenario of some objects:
>>
>> A1 ->> B1, B2, B3
>> A2 ->> B4, B5, B6, B7
>>
>> Then you create a new collection:
>>
>> C = B1, B2, B5, B7
>>
>> What then happens when you call:
>>
>> A1.setB(C)
>>
>> Should it automatically try to reconcile all changes amongst all objects in
>> the object graph (removing objects from A1 and A2) or is this perhaps
>> indicative of a programming error because you mixed two object relationship
>> graphs together? Also, what should happen to B3? Should it be deleted or
>> orphaned?
>>
>> The way Cayenne is currently set up, you have to manually do that, which is
>> perhaps cumbersome, but more exacting.
>>
>> mrg
>>
>>
>> On Fri, Dec 19, 2014 at 9:00 AM, Johannes wrote:
>>>
>>> Good point, I thought reverse relationships are refreshed autimatically.
>>> My expectation was based on the note "... from any kind of
>>> relationship..." at http://cayenne.apache.org/docs/3.0/relationships.html
>>> I will replace the methods!
>>>
>>> I think you are an advanced user, if you only use your own templates and
>>> answer to dev mailinglist. But to offer such a BASIC functionality in
>>> normal generated classes would be a nice service for new users.
>>>
>>> Thanks Johannes
>>>
>>> Am 18.12.2014 um 21:12 schrieb Mike Kienenberger:
As I said before, I think you need to call
removeToManyTarget("${rel.Name}", obj, true); instead of
iterator.remove() and removeAll(), and then you need to call
addToManyTarget() instead of addAll(). Otherwise, you are losing the
reverse relationship changes.
But the rest seems ok.
I'm not saying that adding setList() to the default template is a good
idea, though. I think having it in your custom template is good
enough.
I do everything with custom templates and rarely use the default
cayenne templates.
On Thu, Dec 18, 2014 at 2:58 PM, Johannes wrote:
> Hello,
>
> following the conversation from
>
>>> http://mail-archives.apache.org/mod_mbox/cayenne-user/201412.mbox/%3C548BDF97.1040104%40gmail.com%3E
> there seems to be a common need for having a new method next to
> addXXX, removeXXX a setXXXs in generated classes from CayenneModeler.
>
> I created a first draft
>
>>> https://github.com/jotpe/cayenne/commit/6627c09936285c7650d69f44a95ba2f4b118f2b6
>
> Would anybody be so nice to review it? I'm not sure if these lines can
> run in every environment without trouble. What about tests?
>
> Best regards Johannes
>
>>>
>>>
>>
>
signature.asc
Description: OpenPGP digital signature
Re: setter for toMany in generated classes
Hi Michael,
thank for this scenario.
My intention is to create a simple setter. A List or Set as Parameter is
just a container for the complete amount of elements which should be set.
The method works just on a copy of the List Parameter. When the input
parameter is a persistet ToManyList, it will be downgraded to none
persistent ArrayList.
Calling A1.setB(C) should create
A1 ->> B1, B2, B5, B7
> Should it automatically try to reconcile all changes amongst all
objects in
> the object graph (removing objects from A1 and A2)
No
> Also, what should happen to B3? Should it be deleted or
> orphaned?
I didn't thought yet about orphaned elements. Good point.
No doubt, the relationship to B3 has to be removed. Best would be to
take care about the element as required by the deletion rule.
I guess, I should write the method documentation more clearly.
Regards Johannes
Am 19.12.2014 um 15:11 schrieb Michael Gentry:
> Hi Johannes,
>
> What you consider basic functionality can actually be not so basic.
>
> Consider this scenario of some objects:
>
> A1 ->> B1, B2, B3
> A2 ->> B4, B5, B6, B7
>
> Then you create a new collection:
>
> C = B1, B2, B5, B7
>
> What then happens when you call:
>
> A1.setB(C)
>
> Should it automatically try to reconcile all changes amongst all objects in
> the object graph (removing objects from A1 and A2) or is this perhaps
> indicative of a programming error because you mixed two object relationship
> graphs together? Also, what should happen to B3? Should it be deleted or
> orphaned?
>
> The way Cayenne is currently set up, you have to manually do that, which is
> perhaps cumbersome, but more exacting.
>
> mrg
>
>
> On Fri, Dec 19, 2014 at 9:00 AM, Johannes wrote:
>>
>> Good point, I thought reverse relationships are refreshed autimatically.
>> My expectation was based on the note "... from any kind of
>> relationship..." at http://cayenne.apache.org/docs/3.0/relationships.html
>> I will replace the methods!
>>
>> I think you are an advanced user, if you only use your own templates and
>> answer to dev mailinglist. But to offer such a BASIC functionality in
>> normal generated classes would be a nice service for new users.
>>
>> Thanks Johannes
>>
>> Am 18.12.2014 um 21:12 schrieb Mike Kienenberger:
>>> As I said before, I think you need to call
>>> removeToManyTarget("${rel.Name}", obj, true); instead of
>>> iterator.remove() and removeAll(), and then you need to call
>>> addToManyTarget() instead of addAll(). Otherwise, you are losing the
>>> reverse relationship changes.
>>>
>>> But the rest seems ok.
>>>
>>> I'm not saying that adding setList() to the default template is a good
>>> idea, though. I think having it in your custom template is good
>>> enough.
>>>
>>> I do everything with custom templates and rarely use the default
>>> cayenne templates.
>>>
>>>
>>> On Thu, Dec 18, 2014 at 2:58 PM, Johannes wrote:
Hello,
following the conversation from
>> http://mail-archives.apache.org/mod_mbox/cayenne-user/201412.mbox/%3C548BDF97.1040104%40gmail.com%3E
there seems to be a common need for having a new method next to
addXXX, removeXXX a setXXXs in generated classes from CayenneModeler.
I created a first draft
>> https://github.com/jotpe/cayenne/commit/6627c09936285c7650d69f44a95ba2f4b118f2b6
Would anybody be so nice to review it? I'm not sure if these lines can
run in every environment without trouble. What about tests?
Best regards Johannes
>>
>>
>
signature.asc
Description: OpenPGP digital signature
Re: setter for toMany in generated classes
Hi Johannes,
What you consider basic functionality can actually be not so basic.
Consider this scenario of some objects:
A1 ->> B1, B2, B3
A2 ->> B4, B5, B6, B7
Then you create a new collection:
C = B1, B2, B5, B7
What then happens when you call:
A1.setB(C)
Should it automatically try to reconcile all changes amongst all objects in
the object graph (removing objects from A1 and A2) or is this perhaps
indicative of a programming error because you mixed two object relationship
graphs together? Also, what should happen to B3? Should it be deleted or
orphaned?
The way Cayenne is currently set up, you have to manually do that, which is
perhaps cumbersome, but more exacting.
mrg
On Fri, Dec 19, 2014 at 9:00 AM, Johannes wrote:
>
> Good point, I thought reverse relationships are refreshed autimatically.
> My expectation was based on the note "... from any kind of
> relationship..." at http://cayenne.apache.org/docs/3.0/relationships.html
> I will replace the methods!
>
> I think you are an advanced user, if you only use your own templates and
> answer to dev mailinglist. But to offer such a BASIC functionality in
> normal generated classes would be a nice service for new users.
>
> Thanks Johannes
>
> Am 18.12.2014 um 21:12 schrieb Mike Kienenberger:
> > As I said before, I think you need to call
> > removeToManyTarget("${rel.Name}", obj, true); instead of
> > iterator.remove() and removeAll(), and then you need to call
> > addToManyTarget() instead of addAll(). Otherwise, you are losing the
> > reverse relationship changes.
> >
> > But the rest seems ok.
> >
> > I'm not saying that adding setList() to the default template is a good
> > idea, though. I think having it in your custom template is good
> > enough.
> >
> > I do everything with custom templates and rarely use the default
> > cayenne templates.
> >
> >
> > On Thu, Dec 18, 2014 at 2:58 PM, Johannes wrote:
> >> Hello,
> >>
> >> following the conversation from
> >>
> http://mail-archives.apache.org/mod_mbox/cayenne-user/201412.mbox/%3C548BDF97.1040104%40gmail.com%3E
> >> there seems to be a common need for having a new method next to
> >> addXXX, removeXXX a setXXXs in generated classes from CayenneModeler.
> >>
> >> I created a first draft
> >>
> https://github.com/jotpe/cayenne/commit/6627c09936285c7650d69f44a95ba2f4b118f2b6
> >>
> >> Would anybody be so nice to review it? I'm not sure if these lines can
> >> run in every environment without trouble. What about tests?
> >>
> >> Best regards Johannes
> >>
>
>
Re: setter for toMany in generated classes
Good point, I thought reverse relationships are refreshed autimatically.
My expectation was based on the note "... from any kind of
relationship..." at http://cayenne.apache.org/docs/3.0/relationships.html
I will replace the methods!
I think you are an advanced user, if you only use your own templates and
answer to dev mailinglist. But to offer such a BASIC functionality in
normal generated classes would be a nice service for new users.
Thanks Johannes
Am 18.12.2014 um 21:12 schrieb Mike Kienenberger:
> As I said before, I think you need to call
> removeToManyTarget("${rel.Name}", obj, true); instead of
> iterator.remove() and removeAll(), and then you need to call
> addToManyTarget() instead of addAll(). Otherwise, you are losing the
> reverse relationship changes.
>
> But the rest seems ok.
>
> I'm not saying that adding setList() to the default template is a good
> idea, though. I think having it in your custom template is good
> enough.
>
> I do everything with custom templates and rarely use the default
> cayenne templates.
>
>
> On Thu, Dec 18, 2014 at 2:58 PM, Johannes wrote:
>> Hello,
>>
>> following the conversation from
>> http://mail-archives.apache.org/mod_mbox/cayenne-user/201412.mbox/%3C548BDF97.1040104%40gmail.com%3E
>> there seems to be a common need for having a new method next to
>> addXXX, removeXXX a setXXXs in generated classes from CayenneModeler.
>>
>> I created a first draft
>> https://github.com/jotpe/cayenne/commit/6627c09936285c7650d69f44a95ba2f4b118f2b6
>>
>> Would anybody be so nice to review it? I'm not sure if these lines can
>> run in every environment without trouble. What about tests?
>>
>> Best regards Johannes
>>
signature.asc
Description: OpenPGP digital signature
Re: setter for toMany in generated classes
Thanks for the note: the return collection can differ. Regards Johannes Am 19.12.2014 um 06:18 schrieb David Feshbach: > Set toRemove = new HashSet(getX()); signature.asc Description: OpenPGP digital signature
Re: setter for toMany in generated classes
Here's basically what we have in our template:
Set toRemove = new HashSet(getX());
for (T obj : list) {
if (!toRemove.remove(obj)) {
addX(obj);
}
}
for (T obj : toRemove) {
removeX(obj);
}
Also, it may be better to put all that logic in CayanneDataObject and have
the template just call setToManyRelationship($rel.Name, collection).
- David
On Thu, Dec 18, 2014 at 1:58 PM, Johannes wrote:
>
> Hello,
>
> following the conversation from
>
> http://mail-archives.apache.org/mod_mbox/cayenne-user/201412.mbox/%3C548BDF97.1040104%40gmail.com%3E
> there seems to be a common need for having a new method next to
> addXXX, removeXXX a setXXXs in generated classes from CayenneModeler.
>
> I created a first draft
>
> https://github.com/jotpe/cayenne/commit/6627c09936285c7650d69f44a95ba2f4b118f2b6
>
> Would anybody be so nice to review it? I'm not sure if these lines can
> run in every environment without trouble. What about tests?
>
> Best regards Johannes
>
>
Re: setter for toMany in generated classes
As I said before, I think you need to call
removeToManyTarget("${rel.Name}", obj, true); instead of
iterator.remove() and removeAll(), and then you need to call
addToManyTarget() instead of addAll(). Otherwise, you are losing the
reverse relationship changes.
But the rest seems ok.
I'm not saying that adding setList() to the default template is a good
idea, though. I think having it in your custom template is good
enough.
I do everything with custom templates and rarely use the default
cayenne templates.
On Thu, Dec 18, 2014 at 2:58 PM, Johannes wrote:
> Hello,
>
> following the conversation from
> http://mail-archives.apache.org/mod_mbox/cayenne-user/201412.mbox/%3C548BDF97.1040104%40gmail.com%3E
> there seems to be a common need for having a new method next to
> addXXX, removeXXX a setXXXs in generated classes from CayenneModeler.
>
> I created a first draft
> https://github.com/jotpe/cayenne/commit/6627c09936285c7650d69f44a95ba2f4b118f2b6
>
> Would anybody be so nice to review it? I'm not sure if these lines can
> run in every environment without trouble. What about tests?
>
> Best regards Johannes
>
setter for toMany in generated classes
Hello, following the conversation from http://mail-archives.apache.org/mod_mbox/cayenne-user/201412.mbox/%3C548BDF97.1040104%40gmail.com%3E there seems to be a common need for having a new method next to addXXX, removeXXX a setXXXs in generated classes from CayenneModeler. I created a first draft https://github.com/jotpe/cayenne/commit/6627c09936285c7650d69f44a95ba2f4b118f2b6 Would anybody be so nice to review it? I'm not sure if these lines can run in every environment without trouble. What about tests? Best regards Johannes signature.asc Description: OpenPGP digital signature
setter for toMany in generated classes
Hello, following the conversation from http://mail-archives.apache.org/mod_mbox/cayenne-user/201412.mbox/%3C548BDF97.1040104%40gmail.com%3E there seems to be a common need for having a new method next to addXXX, removeXXX a setXXXs in generated classes from CayenneModeler. I created a first draft https://github.com/jotpe/cayenne/commit/6627c09936285c7650d69f44a95ba2f4b118f2b6 Would anybody be so nice to review it? I'm not sure if these lines can run in every environment without trouble. What about tests? Best regards Johannes signature.asc Description: OpenPGP digital signature
