Criteria objects

From: VisionSet (spam_at_ntlworld.com)
Date: 08/24/04


Date: Tue, 24 Aug 2004 05:14:45 GMT

I think there is a valid approach to retrieving records based on a criteria
object that is of the same class as the object you are retrieving.

A Record object may be used as the criteria to find other Record objects.

If we have a method such as

Record[] find(Record record);

then the argument can have any of its fields as null
this would signify no filtering on that field.

A criteria object could be set up as so:

public Record(Integer key, String[] data);

new Record(null, new String {"Foo", "Bar", null, null, null, null, null})

I think Hibernate uses this approach.

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.

-- 
Mike W


Relevant Pages

  • Criteria objects
    ... I think there is a valid approach to retrieving records based on a criteria ... A Record object may be used as the criteria to find other Record objects. ... But I'm a little unhappy about this, a null primary key? ... should I have a separate criteria class? ...
    (comp.lang.java.programmer)
  • Re: Record Lookup
    ... Dim SelectedRows() As DataRow ... The select method returns all rows matching the criteria. ... primary key in the table to the field that I wanted to use for the search ... Dim drSelectedRecord As DataRow ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Record Lookup
    ... Number or First Name or Last Name or any criteria field I choose and return ... The problem is that a novice can ask more difficult questions than somebody ... primary key in the table to the field that I wanted to use for the search ... a single Access database table and return the value of one field ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Record Lookup
    ... The problem is that a novice can ask more difficult questions than somebody who knows what he wants. ... primary key in the table to the field that I wanted to use for the search ... criteria and that didn't work. ... >>> a single Access database table and return the value of one field ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Record Lookup
    ... Patrice, thank you for your comments and effort. ... primary key in the table to the field that I wanted to use for the search ... criteria and that didn't work. ... Keep in mind.....I am a NOVICE programmer, so you will have to spell it ...
    (microsoft.public.dotnet.languages.vb)