Re: NullPointerException when I commit

From: Mike Kienenberger (mkienen..laska.net)
Date: Fri Jan 14 2005 - 13:39:24 EST

  • Next message: Joshua Pyle: "Re: NullPointerException when I commit"

    What version of Cayenne are you using?

    Are you doing anything else in this context besides deleting objects?
    (inserting/modifying)
    If not, what is the output of "toDelete Before" for each object?

    It's unclear to me how you could end up with a DataObject in a context
    without a valid ObjectID.

                ObjectId id = object.getObjectId();
                if (id.getReplacementId() != null) {

    -Mike

    Joshua Pyle <joshua.t.pyl..mail.com> wrote:
    > This NullPointer Exception is happening consitently Here is the code
    > segment causing this....
    >
    > //Delete all of the permissions
    > int size = currentPermissions.size();
    > for (int i = 0; i < size; i++) {
    > DataObject toDelete = (DataObject) currentPermissions.get(i);
    > System.out.println( "toDelete Before - " + toDelete );
    > dbContext.deleteObject(toDelete);
    > System.out.println( "toDelete After - " + toDelete );
    > }
    >
    > try{
    > dbContext.commitChanges();
    > }catch( Exception e ){
    > dbContext.rollbackChanges();
    > e.printStackTrace( System.out );
    > }
    >
    > This is the exception line...
    >
    > at
    org.objectstyle.cayenne.access.ObjectStore.objectsCommitted(ObjectStore.java:478)
    > at
    org.objectstyle.cayenne.access.ContextCommit.commit(ContextCommit.java:215)
    > at
    org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:1266)
    > at
    org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:1236)
    > at
    com.ray.rms.it.esolutions.mla.view.Admin.User.ProcEditUser.buildPermissionsFromPrograms(ProcEditUser.java:266)
    >
    > I'm assuming either that I'm doing this wrong or there is a bug at
    > ObjectStore.java:478
    >
    > * if (id.getReplacementId() != null) {
    > if (modifiedIds == null) {
    > modifiedIds = new ArrayList();
    > }
    >
    > modifiedIds.add(id);
    >
    > // postpone processing of objects that require an id
    change
    > continue;
    > }



    This archive was generated by hypermail 2.0.0 : Fri Jan 14 2005 - 13:39:30 EST