You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by "Michael Gentry (JIRA)" <de...@cayenne.apache.org> on 2008/06/04 15:59:52 UTC
[jira] Created: (CAY-1065) Add registerNewObjects() method to
DataContext
Add registerNewObjects() method to DataContext
----------------------------------------------
Key: CAY-1065
URL: https://issues.apache.org/cayenne/browse/CAY-1065
Project: Cayenne
Issue Type: New Feature
Components: Cayenne Core Library
Affects Versions: 3.0
Environment: N/A
Reporter: Michael Gentry
Assignee: Michael Gentry
Priority: Minor
Fix For: 3.0
Add registerNewObjects() method to DataContext which is a cover method which calls registerNewObject(). Make at least two methods:
void registerNewObjects(List objects)
void registerNewObjects(Object[] objects)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CAY-1065) Add registerNewObjects() method to
DataContext
Posted by "Robert Zeigler (JIRA)" <de...@cayenne.apache.org>.
[ https://issues.apache.org/cayenne/browse/CAY-1065?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12907#action_12907 ]
Robert Zeigler commented on CAY-1065:
-------------------------------------
I suppose it depends on how the method is implemented, but, assuming a simple implementation:
registerNewObjects(Collection objs) {
for(Object obj : objs) {
registerNewObject(obj);
}
}
you could widen the type even further , to: registerNewObjects(Iterable objs)
Sadly, arrays seem to be "special cased" for the enhanced for loop, rather than implementing "iterable".
None-the-less, it's easy to turn an array into a list w/ java 5:
registerNewObjects(Arrays.asList(myArray));
So you could, in theory at least, have a single method, rather than two.
> Add registerNewObjects() method to DataContext
> ----------------------------------------------
>
> Key: CAY-1065
> URL: https://issues.apache.org/cayenne/browse/CAY-1065
> Project: Cayenne
> Issue Type: New Feature
> Components: Cayenne Core Library
> Affects Versions: 3.0
> Environment: N/A
> Reporter: Michael Gentry
> Assignee: Michael Gentry
> Priority: Minor
> Fix For: 3.0
>
>
> Add registerNewObjects() method to DataContext which is a cover method which calls registerNewObject(). Make at least two methods:
> void registerNewObjects(List objects)
> void registerNewObjects(Object[] objects)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CAY-1065) Add registerNewObjects() method to
DataContext
Posted by "Robert Zeigler (JIRA)" <de...@cayenne.apache.org>.
[ https://issues.apache.org/cayenne/browse/CAY-1065?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12910#action_12910 ]
Robert Zeigler commented on CAY-1065:
-------------------------------------
Just had a thought on this. What's being asked for here is really a bunch of "convenience methods". Whereas "deleteObject" hides all of the complexity of managing the object graph state, the persistence state of the object being deleted, etc., "deleteObjects" is just a wrapper around deleteObject. It doesn't have to be a method in the context interface (or in either CayenneContext or DataContext). What if we had a "ContextUtils" class? Then you could do:
ContextUtils {
public static final void deleteObjects(ObjectContext context, Iterable<?> objs) {
for(Object obj : objs) {
context.deleteObject(obj);
}
}
}
All of the xxxObjects methods could be refactored into ContextUtils.
So then instead of:
context.deleteObjects(objs);
you have:
ContextUtils.deleteObjects(context,objs);
Which doesn't look quite as pretty, but with static imports, that could become:
deleteObjects(context,objs);
Which is no more typing than context.deleteObjects(objs);
More importantly, it keeps the interfaces the same as they were before, and the code becomes re-usable for either a DataContext or a CayenneContext, without having to copy/paste it (or put it in a superclass).
> Add registerNewObjects() method to DataContext
> ----------------------------------------------
>
> Key: CAY-1065
> URL: https://issues.apache.org/cayenne/browse/CAY-1065
> Project: Cayenne
> Issue Type: New Feature
> Components: Cayenne Core Library
> Affects Versions: 3.0
> Environment: N/A
> Reporter: Michael Gentry
> Assignee: Michael Gentry
> Priority: Minor
> Fix For: 3.0
>
>
> Add registerNewObjects() method to DataContext which is a cover method which calls registerNewObject(). Make at least two methods:
> void registerNewObjects(List objects)
> void registerNewObjects(Object[] objects)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CAY-1065) Add registerNewObjects() method to
DataContext
Posted by "Andrey Razumovsky (JIRA)" <de...@cayenne.apache.org>.
[ https://issues.apache.org/cayenne/browse/CAY-1065?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12905#action_12905 ]
Andrey Razumovsky commented on CAY-1065:
----------------------------------------
Then that should be
'void registerNewObjects(*Collection* objects)' i think
> Add registerNewObjects() method to DataContext
> ----------------------------------------------
>
> Key: CAY-1065
> URL: https://issues.apache.org/cayenne/browse/CAY-1065
> Project: Cayenne
> Issue Type: New Feature
> Components: Cayenne Core Library
> Affects Versions: 3.0
> Environment: N/A
> Reporter: Michael Gentry
> Assignee: Michael Gentry
> Priority: Minor
> Fix For: 3.0
>
>
> Add registerNewObjects() method to DataContext which is a cover method which calls registerNewObject(). Make at least two methods:
> void registerNewObjects(List objects)
> void registerNewObjects(Object[] objects)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CAY-1065) Add registerNewObjects() method to
DataContext
Posted by "Mike Kienenberger (JIRA)" <de...@cayenne.apache.org>.
[ https://issues.apache.org/cayenne/browse/CAY-1065?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12911#action_12911 ]
Mike Kienenberger commented on CAY-1065:
----------------------------------------
I agree with Robert and was thinking the same thing when I first saw this JIRA open.
> Add registerNewObjects() method to DataContext
> ----------------------------------------------
>
> Key: CAY-1065
> URL: https://issues.apache.org/cayenne/browse/CAY-1065
> Project: Cayenne
> Issue Type: New Feature
> Components: Cayenne Core Library
> Affects Versions: 3.0
> Environment: N/A
> Reporter: Michael Gentry
> Assignee: Michael Gentry
> Priority: Minor
> Fix For: 3.0
>
>
> Add registerNewObjects() method to DataContext which is a cover method which calls registerNewObject(). Make at least two methods:
> void registerNewObjects(List objects)
> void registerNewObjects(Object[] objects)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CAY-1065) Add registerNewObjects() method to
DataContext
Posted by "Michael Gentry (JIRA)" <de...@cayenne.apache.org>.
[ https://issues.apache.org/cayenne/browse/CAY-1065?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12909#action_12909 ]
Michael Gentry commented on CAY-1065:
-------------------------------------
Robert,
You simple implementation is precisely what I was thinking. I like the idea of using Iterable, too. Makes the most sense and you only need one method then and don't have to provide symmetry with adding new deleteObjects() or unregisterObjects() -- although perhaps their signatures should change to Iterable, too? Or, we could use Collection like Andrey said and that would keep things consistent.
> Add registerNewObjects() method to DataContext
> ----------------------------------------------
>
> Key: CAY-1065
> URL: https://issues.apache.org/cayenne/browse/CAY-1065
> Project: Cayenne
> Issue Type: New Feature
> Components: Cayenne Core Library
> Affects Versions: 3.0
> Environment: N/A
> Reporter: Michael Gentry
> Assignee: Michael Gentry
> Priority: Minor
> Fix For: 3.0
>
>
> Add registerNewObjects() method to DataContext which is a cover method which calls registerNewObject(). Make at least two methods:
> void registerNewObjects(List objects)
> void registerNewObjects(Object[] objects)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
Re: [jira] Commented: (CAY-1065) Add registerNewObjects() method to DataContext
Posted by Andrus Adamchik <an...@objectstyle.org>.
In this case method redundancy in the interface is benign enough (from
the POV of proxying and nesting of contexts), so maybe that's ok.
Andrus
On Jun 4, 2008, at 5:21 PM, Kevin Menard wrote:
> I advocate this being applied to ObjectContext rather than
> DataContext. deleteObjects doesn't exist in ObjectContext, which is
> really quite annoying for the client. I'd hate to see further
> disparity.
>
> --
> Kevin
>
> On Jun 4, 2008, at 10:11 AM, Andrus Adamchik (JIRA) wrote:
>
>>
>> [ https://issues.apache.org/cayenne/browse/CAY-1065?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12906
>> #action_12906 ]
>>
>> Andrus Adamchik commented on CAY-1065:
>> --------------------------------------
>>
>> A few notes:
>>
>> 1. void registerNewObjects(List objects) -> void
>> registerNewObjects(Collection objects)
>>
>> 2. void registerNewObjects(Object[] objects) - no specific
>> objections, but if we do that, than to preserve some symmetry, we
>> need to provide a similar method for deleteObjects,
>> unregsiterObjects, etc. Maybe that's ok... Currently I have no
>> opinion... Also check out Java 5 vararg notation: void
>> registerNewObjects(Object... objects)
>>
>>
>>
>>> Add registerNewObjects() method to DataContext
>>> ----------------------------------------------
>>>
>>> Key: CAY-1065
>>> URL: https://issues.apache.org/cayenne/browse/CAY-1065
>>> Project: Cayenne
>>> Issue Type: New Feature
>>> Components: Cayenne Core Library
>>> Affects Versions: 3.0
>>> Environment: N/A
>>> Reporter: Michael Gentry
>>> Assignee: Michael Gentry
>>> Priority: Minor
>>> Fix For: 3.0
>>>
>>>
>>> Add registerNewObjects() method to DataContext which is a cover
>>> method which calls registerNewObject(). Make at least two methods:
>>> void registerNewObjects(List objects)
>>> void registerNewObjects(Object[] objects)
>>
>> --
>> This message is automatically generated by JIRA.
>> -
>> You can reply to this email to add a comment to the issue online.
>>
>
>
Re: [jira] Commented: (CAY-1065) Add registerNewObjects() method to DataContext
Posted by Kevin Menard <km...@servprise.com>.
I advocate this being applied to ObjectContext rather than
DataContext. deleteObjects doesn't exist in ObjectContext, which is
really quite annoying for the client. I'd hate to see further
disparity.
--
Kevin
On Jun 4, 2008, at 10:11 AM, Andrus Adamchik (JIRA) wrote:
>
> [ https://issues.apache.org/cayenne/browse/CAY-1065?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12906
> #action_12906 ]
>
> Andrus Adamchik commented on CAY-1065:
> --------------------------------------
>
> A few notes:
>
> 1. void registerNewObjects(List objects) -> void
> registerNewObjects(Collection objects)
>
> 2. void registerNewObjects(Object[] objects) - no specific
> objections, but if we do that, than to preserve some symmetry, we
> need to provide a similar method for deleteObjects,
> unregsiterObjects, etc. Maybe that's ok... Currently I have no
> opinion... Also check out Java 5 vararg notation: void
> registerNewObjects(Object... objects)
>
>
>
>> Add registerNewObjects() method to DataContext
>> ----------------------------------------------
>>
>> Key: CAY-1065
>> URL: https://issues.apache.org/cayenne/browse/CAY-1065
>> Project: Cayenne
>> Issue Type: New Feature
>> Components: Cayenne Core Library
>> Affects Versions: 3.0
>> Environment: N/A
>> Reporter: Michael Gentry
>> Assignee: Michael Gentry
>> Priority: Minor
>> Fix For: 3.0
>>
>>
>> Add registerNewObjects() method to DataContext which is a cover
>> method which calls registerNewObject(). Make at least two methods:
>> void registerNewObjects(List objects)
>> void registerNewObjects(Object[] objects)
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
[jira] Commented: (CAY-1065) Add registerNewObjects() method to
DataContext
Posted by "Andrus Adamchik (JIRA)" <de...@cayenne.apache.org>.
[ https://issues.apache.org/cayenne/browse/CAY-1065?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12906#action_12906 ]
Andrus Adamchik commented on CAY-1065:
--------------------------------------
A few notes:
1. void registerNewObjects(List objects) -> void registerNewObjects(Collection objects)
2. void registerNewObjects(Object[] objects) - no specific objections, but if we do that, than to preserve some symmetry, we need to provide a similar method for deleteObjects, unregsiterObjects, etc. Maybe that's ok... Currently I have no opinion... Also check out Java 5 vararg notation: void registerNewObjects(Object... objects)
> Add registerNewObjects() method to DataContext
> ----------------------------------------------
>
> Key: CAY-1065
> URL: https://issues.apache.org/cayenne/browse/CAY-1065
> Project: Cayenne
> Issue Type: New Feature
> Components: Cayenne Core Library
> Affects Versions: 3.0
> Environment: N/A
> Reporter: Michael Gentry
> Assignee: Michael Gentry
> Priority: Minor
> Fix For: 3.0
>
>
> Add registerNewObjects() method to DataContext which is a cover method which calls registerNewObject(). Make at least two methods:
> void registerNewObjects(List objects)
> void registerNewObjects(Object[] objects)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.