Re: Subclassing a DataObject

From: Mike Kienenberger (mkienen..laska.net)
Date: Thu Jun 30 2005 - 18:36:58 EDT


Kevin Menard <kmenar..ervprise.com> wrote:
> Mike Kienenberger wrote:
>
> > There's probably a better way to solve your testing problem, but I don't

> > have enough info (either that, or enough brain cells) to provide any
ideas.
>
> Hmm . . . there are certainly other ways, and they are better than
> adding another DataMap. The goal here is transparency. In the general
> case, the rest of the system uses interfaces, so it's not particularly
> bound to the DataObject. But it'd be nice if the client didn't really
> need to know about Cayenne rules when looking to subclass.

I think I understand the issue better now after having given what I sent you
earlier some thought.

Cayenne cannot instantiate your subclass because all DataObjects are
instantiated by class name.

Perhaps you can just programmically update your data map with the new class
name for the test subclass.

> Perhaps the velocity templates should be updated to make these generated
> classes final then?

Maybe. I'll let Andrus chime in on that one. It does seem like it might
be a good idea. On the other hand, since you can modify the DataMap to
provide a different name, then it's possible that what might be a "final"
class for one DataMap may not be the final class in another DataMap.

This would especially be true once you start dealing with supporting
inheritance, although the template could certainly detect those cases.



This archive was generated by hypermail 2.0.0 : Thu Jun 30 2005 - 18:34:07 EDT