Re: findReference, or create it ?

Franck Routier <[email protected]> Tue, 27 Jan 2009 17:55:15 +0100
Newsgroups gmane.comp.java.orm.simpleorm
Organization Axège Sarl
Message-ID <1233075315.22811.26.camel@franck-laptop>
Hi Anthony,

Thanks for reviewing my changes.

I have added tests (in BasicTests) to test the various cases you
mention.
Everything seems to works fine...

> 
> What happens if a record is created, with initial value on column C
> that is not later set. C is not dirty, so does not get inserted. Then
> it is read again. Do we reinitialize the values? How do we know that
> they were not deliberately set to null (say)?

C will be set on insertion, as the field really is made dirty. If the
value is set to anything else, the value given by the user (or the
database) will be preserved, be it null or anything else. See the tests.

> 
> I also noted
> this.setRawArrayValue(fld, fld.getInitialValue())
> We normally cook the values a bit, which sets dirty. I see why you
> used raw, but it may not be quite right. Have a think. Needs
> documenting.

In fact a column C is dirty if its raw value is not INVALID_VALUE and it
is not equal to its optimisitc value. So setting the initial value in
raw array on a newly created record makes it dirty.

I added a comment on that in the code.

> Need to document that no DDL is generated.

Done.

> 
> Your observation on references seems sound. Really, the only way that
> there could be a reference to a row that does not exist is if the
> database is corrupted somehow. So Find would seem to make more sense.
> So my initial reaction is to change it to a find, no create, exception
> if not found. Be sure to put this slight incompatibility in the change
> log.

The point here is that findReference lives in dataset package. So the
reference might not be present in the dataset, even if everything is
fine in the database.
Also doing a find implies adding the find method in the ISSession
interface... So I'll do that as you suggest.

Regards,

Franck




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

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/SimpleORM/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/SimpleORM/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[email protected] 
    mailto:[email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/