Hmm, my first guess was T4. I had issues using the new..or/@If/etc
components with T4 -- I had to set the volatile="true" parameter on them
or my Cayenne objects would get whacked (still don't understand that
exactly).
Back to your issue. I'm guessing the DC in your session is OK (that
seemed to work fine for me in T3). How is the author (or the container
of author) being kept in memory? Do you have it as a Tapestry
page-persistent variable (the property-specification's persist="yes")?
If you are storing it that way and the author (or container of author)
isn't serializable, I think you'll get a hollow object back from
Cayenne. I seem to recall something along that line from many many
months ago, but could be off a tad. Hmm, your author is probably
serializable (it's a CayenneDataObject), but check to see what it is
being stored in.
/dev/mrg
-----Original Message-----
From: Todd O'Bryan [mailto:toddobrya..ac.com]
Sent: Tuesday, February 21, 2006 6:56 PM
To: cayenne-use..bjectstyle.org
Subject: Re: Validation error that shouldn't be (I don't think)
T3, still. And, yes, the Visit is Serializable. (I just checked to be
sure.)
Todd
On Feb 21, 2006, at 11:15 AM, Gentry, Michael (Contractor) wrote:
> Todd, are you using T3 or T4? Your session is serializable, right?
>
> Thanks,
>
> /dev/mrg
>
>
> -----Original Message-----
> From: Todd O'Bryan [mailto:toddobrya..ac.com]
> Sent: Monday, February 20, 2006 6:53 AM
> To: cayenne-use..bjectstyle.org
> Subject: Re: Validation error that shouldn't be (I don't think)
>
>
> OK. I'm stumped...here's the whole code for the method that's causing
> the problem, along with the exception iterator that Andrus suggested
> at the bottom, and a few other print statements sprinkled throughout.
> I should emphasize that, if I include the if statement that's
> commented out, this works. (Note also that the dbQuestions are always
> null; I haven't even *started* testing the else.
>
> public void commitToDb(DataContext dc) {
> System.out.println(getAuthor());
> /*if (getAuthor().getPersistenceState() ==
> PersistenceState.HOLLOW) {
> setAuthor((User)
> dc.refetchObject(getAuthor().getObjectId()));
> }*/
> try {
> if (dbQuestion == null) {
> // create new one
> dbQuestion = (ObQuestion)
> dc.createAndRegisterNewObject
> (ObQuestion.class);
> dbQuestion.setAuthor(getAuthor());
> dbQuestion.setType(getType());
> dbQuestion.setIsVetted(Boolean.FALSE);
>
> dbQuestion.addToData(ObQuestionDatum.createNew(dc, TEXT, getText
> (), null));
>
> dbQuestion.addToData(ObQuestionDatum.createNew(dc, EXPLANATION,
> getExplanation(), null));
>
> dbQuestion.addToData(ObQuestionDatum.createNew(dc, CORRECT_NUMBER,
> null, getCorrectNumber()));
> for (int i = 0; i < getChoices().length; i++) {
>
> dbQuestion.addToData(ObQuestionDatum.createNew(dc, CHOICES,
> getChoices()[i], i));
> }
> } else {
> //update the one we've got
> dbQuestion.getValue(TEXT).setText(getText());
>
> dbQuestion.getValue(EXPLANATION).setText(getExplanation());
>
> dbQuestion.getValue(CORRECT_NUMBER).setNumericValue
> (getCorrectNumber());
> List<ObQuestionDatum> dbChoices =
> dbQuestion.getValues(CHOICES);
> for (ObQuestionDatum choice : dbChoices) {
>
> choice.setText(getChoices()[choice.getNumericValue()]);
> }
> }
> dbQuestion.setLastModified(new Date());
> dbQuestion.getDataContext().commitChanges();
> } catch (ValidationException e) {
> System.out.println(getAuthor());
> Iterator it =
> e.getValidationResult().getFailures().iterator();
> while(it.hasNext()) {
> ValidationFailure f = (ValidationFailure)
> it.next();
> Object source = f.getSource();
> System.out.println(source);
> }
>
> }
> }
>
> Here are the results of the print statements, with labels:
>
> This is the first print, the result of getAuthor()
> {<ObjectId:User, id=221>; hollow; []}
>
> This is getAuthor() after setting the value in the database
> {<ObjectId:User, id=221>; new; [toUserPages=>?; organizations=>?;
> studentSections=>?; toOutMessages=>?; exchanges=>?; toAssignments=>?;
> teacherSections=>?; files=>?; toSkins=>?; groups=>?;
> studentForums=>?; obligations=>?; toInMessages=>?; toGrades=>?;
> toTardys=>?; absences=>?; teacherForums=>?; messages=>?;
> toAnswers=>?]}
>
> These are all the problems from iterating through the
> ValidationException
> {<ObjectId:User, id=221>; new; [toUserPages=>?; organizations=>?;
> studentSections=>?; toOutMessages=>?; exchanges=>?; toAssignments=>?;
> teacherSections=>?; files=>?; toSkins=>?; groups=>?;
> studentForums=>?; obligations=>?; toInMessages=>?; toGrades=>?;
> toTardys=>?; absences=>?; teacherForums=>?; messages=>?;
> toAnswers=>?]}
> {<ObjectId:User, id=221>; new; [toUserPages=>?; organizations=>?;
> studentSections=>?; toOutMessages=>?; exchanges=>?; toAssignments=>?;
> teacherSections=>?; files=>?; toSkins=>?; groups=>?;
> studentForums=>?; obligations=>?; toInMessages=>?; toGrades=>?;
> toTardys=>?; absences=>?; teacherForums=>?; messages=>?;
> toAnswers=>?]}
> {<ObjectId:User, id=221>; new; [toUserPages=>?; organizations=>?;
> studentSections=>?; toOutMessages=>?; exchanges=>?; toAssignments=>?;
> teacherSections=>?; files=>?; toSkins=>?; groups=>?;
> studentForums=>?; obligations=>?; toInMessages=>?; toGrades=>?;
> toTardys=>?; absences=>?; teacherForums=>?; messages=>?;
> toAnswers=>?]}
> {<ObjectId:User, id=221>; new; [toUserPages=>?; organizations=>?;
> studentSections=>?; toOutMessages=>?; exchanges=>?; toAssignments=>?;
> teacherSections=>?; files=>?; toSkins=>?; groups=>?;
> studentForums=>?; obligations=>?; toInMessages=>?; toGrades=>?;
> toTardys=>?; absences=>?; teacherForums=>?; messages=>?;
> toAnswers=>?]}
> {<ObjectId:User, id=221>; new; [toUserPages=>?; organizations=>?;
> studentSections=>?; toOutMessages=>?; exchanges=>?; toAssignments=>?;
> teacherSections=>?; files=>?; toSkins=>?; groups=>?;
> studentForums=>?; obligations=>?; toInMessages=>?; toGrades=>?;
> toTardys=>?; absences=>?; teacherForums=>?; messages=>?;
> toAnswers=>?]}
> {<ObjectId:User, id=221>; new; [toUserPages=>?; organizations=>?;
> studentSections=>?; toOutMessages=>?; exchanges=>?; toAssignments=>?;
> teacherSections=>?; files=>?; toSkins=>?; groups=>?;
> studentForums=>?; obligations=>?; toInMessages=>?; toGrades=>?;
> toTardys=>?; absences=>?; teacherForums=>?; messages=>?;
> toAnswers=>?]}
>
> As I look at the code, could the problem be that the author and the
> dbQuestion are in different DataContexts? If so, I thought I'd get an
> error about not being able to set getAuthor() as a relationship, but
> that would explain why refetching into this DataContext works. (As I
> said before, the DataContext is stored as a Session variable per
> user, so I can't figure out how I'm getting multiple DataContexts for
> one user.)
>
> What am I doing wrong?????
>
> TIA,
> Todd
>
This archive was generated by hypermail 2.0.0 : Wed Feb 22 2006 - 09:18:22 EST