help: Why is there validation w/ a delete action

From: Chad Smith (chadksmith..mail.com)
Date: Thu Jul 03 2008 - 10:45:08 EDT

  • Next message: Scott Anderson: "RE: help: Why is there validation w/ a delete action"

    Can someone tell me why I get a "Cayenne validation" exception when I'm
    trying to delete an object? Here is the stack trace ...

    ------------------------------------------------------------
    Caused by: org.apache.cayenne.validation.ValidationException: [v.2.0.3
    May 6 2007] Validation has failed.
    Validation failure for com.gteam.gtools.knowledgeBase.Topic.updateDate:
    "updateDate" is required.
    Validation failure for com.gteam.gtools.knowledgeBase.Topic.topic:
    "topic" is required.
    Validation failure for com.gteam.gtools.knowledgeBase.Topic.validFlag:
    "validFlag" is required.
    Validation failure for
    com.gteam.gtools.knowledgeBase.Topic.updateUserId: "updateUserId" is
    required.
        at
    org.apache.cayenne.access.ObjectStoreGraphDiff.validateAndCheckNoop(ObjectStoreGraphDiff.java:112)
        at
    org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:1209)
        at
    org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:1130)
        at com.gteam.gtools.cayenne.CayenneDao.delete(CayenneDao.java:166)
        at
    com.gteam.gtools.knowledgeBase.KnowledgeBaseDao.delete(KnowledgeBaseDao.java:94)

    ------------------------------------------------------------

    ... here is the code that generates the exception ...

    ------------------------------------------------------------
    DAO class ...

        public boolean deleteTopic(int topicId) throws DataAccessException {
            Topic topic = loadTopic(topicId);
            this.delete(topic);
            return true;
        }

    DAO super class ...

        public boolean delete(Object object) throws DataAccessException {
            
    ((CayenneDataObject)object).getDataContext().deleteObject((Persistent)object);
            if (Transaction.getThreadTransaction() == null) {
                ((CayenneDataObject)object).getDataContext().commitChanges();
                if (debug)
                    log.debug("CayenneDao >>> thread transaction not present
    committing");
            } else {
                if (debug)
                    log.debug("CayenneDao >>> thread transaction present
    commit deferred");
            }
            return true;
        }
    ------------------------------------------------------------
    ... all my DAO's subclass a CayenneDao object.

    It's not at all clear to me why validation happens on a delete event ???

    thanks in advance.

    Chad



    This archive was generated by hypermail 2.0.0 : Thu Jul 03 2008 - 10:46:53 EDT