Re: Cayenne modeler - need to generate setters and getters for primary key

From: Jürgen Saar (jsaa..eb.de)
Date: Thu Mar 10 2005 - 03:04:54 EST

  • Next message: Laszlo Spoor: "RE: Primary key and sequence"

    Sorry, you'r right, there is a second ant-task I've written
    and there the PK-Fields are connected to the ObjAttribute.

    But this only makes sense for connecting cayenne to
    'historically grown' projects ... new projects should
    not have meaningful PKs

    cayenne-use..bjectstyle.org schrieb am 09.03.05 15:37:59:
    >
    > Getter - maybe (via DataObjectUtils), but if a PK is not mapped as
    > ObjAttribute, how do you implement your setter?
    >
    > Andrus
    >
    >
    > > As I often mentioned, Class generation is done by Velocity,
    > > so you could write your own template, which creates
    > > getter and setter for the PK-attributes
    > >
    > > cayenne-use..bjectstyle.org schrieb am 08.03.05 22:51:49:
    > >>
    > >> Hi Arun,
    > >>
    > >> The problem is not that the id Java attribute is not *generated*,
    > >> rather it is not *mapped*. Once you map it, it will be picked up by
    > >> code generation template. To do that, manually add an ObjAtribute to
    > >> the ObjEntity in question (select an entity in question -
    > >> http://objectstyle.org/cayenne/images/modeler/icon-objentity.gif,
    > >> click on attributes tab, then click Add Attribute -
    > >> http://objectstyle.org/cayenne/images/modeler/icon-attribute.gif) and
    > >> select your PK column from the dropdown.
    > >>
    > >> Andrus
    > >>
    > >>
    > >> > I have an already existing database table that has a meaningful
    > >> primary key (say, the government issued Social Security Number). I
    > >> need to access and display this primary key just like any attribute
    > >> of the object generated for the table. The Cayenne modeler, by
    > >> default, does not seem to generate a setter or a getter for the
    > >> primary key in the generated classes. How do I make it generate a
    > >> setter and a getter for the primary key ?
    > >> >
    > >> > Please note that section 4.7.1 of the Cayenne 1.1 User Guide
    > >> > (http://www.objectstyle.org/cayenne/userguide/design/autopk.html)
    > >> briefly mentions this situation but does not say how to make the
    > >> modeler handle this situation.
    > >> >
    > >> > Any help is appreciated,
    > >> >
    > >> > Arun Shankar
    > >> >
    > >>
    > >>
    > >
    > >
    > > __________________________________________________________
    > > Mit WEB.DE FreePhone mit hoechster Qualitaet ab 0 Ct./Min.
    > > weltweit telefonieren! http://freephone.web.de/?mc=021201
    >
    >
    >

    __________________________________________________________
    Mit WEB.DE FreePhone mit hoechster Qualitaet ab 0 Ct./Min.
    weltweit telefonieren! http://freephone.web.de/?mc=021201



    This archive was generated by hypermail 2.0.0 : Thu Mar 10 2005 - 03:05:00 EST