Primary keys in expressions

From: Dave Merrin (dmerri..pasystems.co.uk)
Date: Thu Feb 02 2006 - 09:18:40 EST

  • Next message: Florian.Esk..i-de.com: "Performance problem 1.2"

    Hi,

    I want to be able to use a primary key in expressions. I see there are two
    possible ways of doing this. The first is to prefix the column name with
    'db:'. The second is to set up another mapping in my map file from an
    objentity to the existing dbentity.

    Which is the best way?

    If I set up another mapping would I be able to simplify the following code:

       public Long getItemTypeId() {
          return (getObjectId() != null && !getObjectId().isTemporary())
                   ?
    (Long)getObjectId().getIdSnapshot().get(ITEM_TYPE_ID_PK_COLUMN)
                   : null;
       }

    to this:
        public String getItemTypeId() {
            return (String)readProperty(ITEM_TYPE_ID_PK_COLUMN);
        }

    And while I'm looking at this code why doesn't the generated code for normal
    properties use the constants i.e.

        public static final String DESCRIPTION_PROPERTY = "description";

        public String getDescription() {
            return (String)readProperty("description");
        }

    Cheers,

    Dave



    This archive was generated by hypermail 2.0.0 : Thu Feb 02 2006 - 09:20:40 EST