Michael, Thank you, i already saw it, but my intent was to make it entirely outside cayenne mappings, the problem i need to solve is just behavioral, not data based... by the way, it's not clear how to try the example using the modeler: creating an empty class with no attributes or something.
Hans ----- "Michael Gentry" <[email protected]> escribió: > Is this what you are after? > > http://cayenne.apache.org/doc/handling-inheritance.html > > > On Sun, Mar 1, 2009 at 7:46 PM, <[email protected]> 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 > > > > > > -- Hans Poo, WeLinux S.A. Oficina: 697.25.42, Celular: 09-319.93.05 Bombero Ossa # 1010, Santiago
