You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Joe Baldwin <jf...@earthlink.net> on 2010/03/23 16:54:06 UTC

SubClassing DataObjects

I have a question about management & usage of the data objects generated by Cayenne Modeler (CM).

It is clear that the CM auto-generates classes that represent the entities built using CM (with the underscore prefix).  In addition, it auto-generates a sub-class.  Also, when any change is made via CM, the sub-classes are regenerated.

I am a little unclear as to the intended management/usage of this sub-class.  Any changes made to the auto-gen sub-class would be lost when the next CM change is made.  So this leaves me with two options: I can either sub-class the sub-class (which does not look like the intended usage of the CM's work), or I can make a separate directory structure with the subclasses and then replace the auto-gen dir of sub-classes (which again does not look like the intended best use of the CM's work).

So this leaves me with the notion that I may be misunderstanding how to manage the sub-classes and make permanent changes that will exist past the next CM code generation procedure.

Thanks,
Joe


Re: SubClassing DataObjects

Posted by Joe Baldwin <jf...@earthlink.net>.
Michael,


> You are supposed to be able to safely put code in the subclass without it being overwritten.

Thanks.  I just tested this and it does in fact preserve the subclass if it already exists.

Joe



Re: SubClassing DataObjects

Posted by Michael Gentry <mg...@masslight.net>.
On Tue, Mar 23, 2010 at 11:54 AM, Joe Baldwin <jf...@earthlink.net> wrote:
> I have a question about management & usage of the data objects generated by Cayenne Modeler (CM).
>
> It is clear that the CM auto-generates classes that represent the entities built using CM (with the underscore prefix).  In addition, it auto-generates a sub-class.  Also, when any change is made via CM, the sub-classes are regenerated.

CM isn't supposed to regenerate the subclass, only the superclass (the
one with the underscore prefix).

> I am a little unclear as to the intended management/usage of this sub-class.  Any changes made to the auto-gen sub-class would be lost when the next CM change is made.  So this leaves me with two options: I can either sub-class the sub-class (which does not look like the intended usage of the CM's work), or I can make a separate directory structure with the subclasses and then replace the auto-gen dir of sub-classes (which again does not look like the intended best use of the CM's work).

You are supposed to be able to safely put code in the subclass without
it being overwritten.  If your subclass IS being overwritten, you have
a different issue going on.  CM will, however, create the subclass for
you automatically if it doesn't already exist, but after that, it
should be hands-off.

> So this leaves me with the notion that I may be misunderstanding how to manage the sub-classes and make permanent changes that will exist past the next CM code generation procedure.
>
> Thanks,
> Joe
>
>