S
Sudsy
VisionSet wrote:
It's a perfectly valid approach (and one I've used). When you pass
value-objects containing record data, using the same for search
criteria makes sense. Ignore those fields which have been set to
null and only search on the populated fields, even if they are
empty Strings. So you're not actually searching for a null primary
key in your example. You're indicating that you haven't specified
the key and to not use it as part of the selection.
I should mention that if the database generates the primary key
automatically then setting it to null in the constructor is
perfectly valid when creating a new record.
But I'm a little unhappy about this, a null primary key?
Is this abuse of the object? should I have a separate criteria class?
I'm after the simplest design that I do feel happy about.
It's a perfectly valid approach (and one I've used). When you pass
value-objects containing record data, using the same for search
criteria makes sense. Ignore those fields which have been set to
null and only search on the populated fields, even if they are
empty Strings. So you're not actually searching for a null primary
key in your example. You're indicating that you haven't specified
the key and to not use it as part of the selection.
I should mention that if the database generates the primary key
automatically then setting it to null in the constructor is
perfectly valid when creating a new record.