[ 
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.

Reply via email to