+1 on adding this option to the Modeler. Somebody please open a Jira.
Andrus
On Jan 22, 2009, at 10:23 PM, Mike Kienenberger wrote:
> I think Martin's issue is that he has meaningful primary keys, and he
> wants to have primary key accessors with meaningful names.
>
> Ie, for an Account table, he might want to have "getAccountNumber()"
> or for a User table, he might want to have "getUserName()" (assuming
> these are the primary key fields). And since there are a lot of
> these, he wants to have them generated automatically with reverse
> engineering.
>
> If it were me, I guess I'd take a look at the reverse engineering code
> and put in some kind of conditional flag to handle primary key fields
> the same as all other fields (there must be some kind of check already
> in there that treats them differently, so this new field would simply
> stop treating them differently.
>
> Sounds like a pretty simple "first patch" for the modeler (as simple
> as any modeler patch gets).
>
>
>
> On Thu, Jan 22, 2009 at 3:00 PM, Robert Zeigler
> <robert.zeigle..mail.com> wrote:
>> What about having all of your entities extend from a common
>> superclass that
>> defines a getter for the pk?
>> For instance, for many applications, I use a simple int primary
>> key, so my
>> entities all extend from a common superclass, with a method ala:
>>
>> public int getPK() {
>> return DataObjectUtils.intPKForObject(this);
>> }
>>
>> Or even:
>>
>> public Object getPK() {
>> return DataObjectUtils.pkForObject(this);
>> }
>>
>> to be more general.
>>
>> Or you could use generics:
>>
>> public <T> T primaryKey(Class<T> type) {
>> return type.cast(DataObjectUtils.pkForObject(this));
>> }
>>
>> and have all sorts of fun with wrappers, like:
>>
>> public Integer intPK() {
>> return primaryKey(Integer.class);
>> }
>>
>> Cheers,
>>
>> Robert
>>
>> On Jan 22, 2009, at 1/221:47 PM , wwwebi wrote:
>>
>>> Hi,
>>>
>>> is there a possibility to create for all objects a getter method
>>> on the
>>> primary key fields within the process of reverse engineering ?
>>>
>>> I have a legacy database where the primary keys are used in a
>>> similar way
>>> as a passport no and as I need it for 100+ tables I wondered if I
>>> could not
>>> at least get a getter method of the primary key fields during
>>> reverse
>>> engineering. Setting it afterwards following this faq
>>> http://cwiki.apache.org/CAY/mapping-primary-keys.html is too time
>>> consuming.
>>> I don't see even an issue only with a getter method.
>>>
>>> If it's not possible within the modeler I would certainly like to
>>> see this
>>> as an option during reverse engineering in the future :-)
>>>
>>> Cheers,
>>> Martin
>>
>>
>
This archive was generated by hypermail 2.0.0 : Fri Jan 23 2009 - 02:43:54 EST