Presenting the DataObjects as interfaces to the application

From: Mike Kienenberger (mkienen..mail.com)
Date: Fri Sep 09 2005 - 14:25:11 EDT

  • Next message: Gili: "Re: Reverse relationships and registeration"

    Based on previous difficulties with unit testing and representing
    transient instances of a DataObject, I've worked out some templates to
    generate interfaces as well as Cayenne implementations of my
    DataObjects.

    Ie, I have these object hierarchies:

      Classes:
        CayenneDataObject -> MyBaseDataObjectImpl -> _DataObjectImpl ->
    DataObjectImpl

    and

      Interfaces:
        MyBaseDataObject -> _DataObject -> DataObject

    where each *Impl object implements the corresponding * interface.

    I'm curious to know if anyone else has tried to do something similar.

    A couple of things I've noticed so far are that I need to convert from
    an interface to a DataObject when working with relationships. I
    don't see that as a big deal since trying to mix a nonDO with a DO is
    an error anyway.

        public void setContent(Content content) {
            setToOneTarget("content", (ContentImpl)content, true);
        }
        public void addToViewpointList(Viewpoint obj) {
            addToManyTarget("viewpointList", (ViewpointImpl)obj, true);
        }
        public void removeFromViewpointList(Viewpoint obj) {
            removeToManyTarget("viewpointList", (ViewpointImpl)obj, true);
        }

    I'm also copying each of the static property strings from the
    interface to the class:

        public static final String VIEWPOINT_LIST_PROPERTY =
    _Announcement.VIEWPOINT_LIST_PROPERTY;

        public static final String ANNOUNCEMENT_ID_PK_COLUMN =
    _Announcement.ANNOUNCEMENT_ID_PK_COLUMN;

    Anyone have any comments on this approach?



    This archive was generated by hypermail 2.0.0 : Fri Sep 09 2005 - 14:25:12 EDT