Is this what you are after?
http://cayenne.apache.org/doc/handling-inheritance.html
On Sun, Mar 1, 2009 at 7:46 PM, <han..elinux.cl> wrote:
> Hi,
>
> I'm trying to implement a factory method pattern based on a cayenne data object.
>
> Say for example i have a class (cayenne based) called Artist, i want to make a subclass of Artist, say ExpertArtist that implements some specific behavior.
>
> Actually i have a big static Factory class that give me the all objects, i have a method like this:
>
> public static Artist getArtist(String id) {
>
> if (id == null || id.equals(""))
> return null;
>
> DataContext context = DataContext.getThreadDataContext();
>
> Artist object = (Artist) DataObjectUtils.objectForPK(
> context, Artist.class, Integer.parseInt(id));
> return object;
> }
>
> Obviously i can declare ExpertArtist as an subclass of Artist.
>
> package xxx.xxx;
>
> public class EspertArtist extends Artist {
> public String getName() {
> return super.getName() + " i'am expert !!";
> }
> }
>
> I've tried to instantiate an ExpertArtist, just modifying the Factory method, with no results. I don't know how to bouild the parent class calling super or something...
>
> Obviously these are not the real classes, the actual classes are really big and this solution: just modifying the factory method is the best for me.
>
>
> Thanks
> Hans
>
>
>
This archive was generated by hypermail 2.0.0 : Mon Mar 02 2009 - 08:41:25 EST