RE: cayenne get accessors

From: Gentry, Michael \(Contractor\) ("Gentry,)
Date: Tue Apr 04 2006 - 11:01:35 EDT

  • Next message: Andrus Adamchik: "Re: cayenne get accessors"

    Having the get prefix makes it beanie. This is really important when
    using other tools, such as OGNL in Tapestry, which you mentioned
    earlier. OGNL expects the get prefix when evaluating the expressions.

    /dev/mrg

    -----Original Message-----
    From: Cyp her [mailto:cypher6..otmail.com]
    Sent: Tuesday, April 04, 2006 10:59 AM
    To: cayenne-use..ncubator.apache.org
    Subject: cayenne get accessors

    Hi

    Does Cayenne force you to have *get* before your property name to create

    your get accessor e.g. getName().

    I have a table like this

    PERSON
       id
       firstName
       lastName

    and the Modeler creates these accessors

    public class _Person extends CayenneDataObject {

       public String getFirstName() ...
       public String getLastName() ...

    }

    Which is fine. I have read you can get custom templates to change this
    and I
    did try by grabbing the default templates from the jar and modifying
    them
    but this did not work. Does anybody know how?

    My real problems start here however. In the subclass Person I have this
    code

    public class Person extends _Person {

            public String fullName() {
                    return this.getFirstName() + " " + this.getLastName();
            }
    }

    and when I try and use and Expression to get a particular Person like
    this

    Expression fullNameQualifier = ExpressionFactory.matchExp("fullName",
    "John
    Doe");

    List filteredPersons = fullNameQualifier.filterObjects(personsList);

    The List is always empty even though I do have a person named John Doe
    in my
    database (MySQL). But oddly enough if I change my method in the Person
    class
    to be this

    public class Person extends _Person {

            public String getFullName() {
                    return this.getFirstName + " " + this.getLastName;
            }
    }

    i.e. change the method name to be getFullName instead of just fullName.

    Why must I prefix all my get accessors with *get*? I want to get rid of
    *get* in all the super classes too so does anyone have a template I can
    use
    to oust them?

    Lawrence

    _________________________________________________________________
    Be the first to hear what's new at MSN - sign up to our free
    newsletters!
    http://www.msn.co.uk/newsletters



    This archive was generated by hypermail 2.0.0 : Tue Apr 04 2006 - 11:02:06 EDT