[jira] Commented: (CAY-1065) Add registerNewObjects() method to DataContext

From: Robert Zeigler (JIRA) ("Robert)
Date: Wed Jun 04 2008 - 14:59:52 EDT

  • Next message: Mike Kienenberger (JIRA): "[jira] Commented: (CAY-1065) Add registerNewObjects() method to DataContext"

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



    This archive was generated by hypermail 2.0.0 : Wed Jun 04 2008 - 15:00:22 EDT