Re: Validation error that shouldn't be (I don't think)

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Sun Feb 19 2006 - 19:27:33 EST

  • Next message: Todd O'Bryan: "Re: Validation error that shouldn't be (I don't think)"

    On Feb 19, 2006, at 9:48 AM, Todd O'Bryan wrote:

    >
    > I have another object which has a User as its author. I set this by
    > doing
    >
    > object.setAuthor(getUser());
    >
    > When I try to commit, I get lots of errors about the user saying
    > that mandatory fields haven't been set. So I printed the User I was
    > trying to set as the author, and it turns out that it's
    >
    > {[]<oid: <ObjectId:User, id=221>; state: hollow>}

    I suspect you are printing the wrong object. You need to catch the
    ValidationException and iterate through the failures to see what
    objects caused them:

    ValidationException e;
    Iterator it = e.getValidationResult().getFailures().iterator();
    while(it.hasNext()) {
       ValidationFailure f = (ValidationFailure) it.next();
       Object source = f.getSource();
       ...
    }

    Andrus



    This archive was generated by hypermail 2.0.0 : Sun Feb 19 2006 - 19:27:36 EST