cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chad Smith <chadksmi...@gmail.com>
Subject help: Why is there validation w/ a delete action
Date Thu, 03 Jul 2008 14:45:08 GMT
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

Mime
View raw message