Re: Mapping hierarchy in one table problem
"Alessandro Colantoni" <[email protected]> Mon, 11 Feb 2008 13:03:32 +0100
| Newsgroups | gmane.comp.jakarta.ojb.user |
|---|---|
| Message-ID | <[email protected]> |
Just having a first superficial look. I see in your code GenericDAOApacheOJB<GrandChildObject, Long> grandChildProjectDao I didn't see GrandChildObject anywere else in your mapping, but maybe I'm not seeing well. Shouldn't it be GenericDAOApacheOJB<GrandChildProject, Long> ? On 2/11/08, Schmidt <[email protected]> wrote: > > > Hi Armin, > > Thanks again. > In order to query the database for GrandChildProject objects, I use a > generic class that extends PersistenceBrokerDaoSupport: > > public class GenericDAOApacheOJB<T, PK> extends > PersistenceBrokerDaoSupport > { > > private Class<T> persistentClass; > > public T getById(PK id) throws DataAccessException{ > return (T) > this.getPersistenceBrokerTemplate().getObjectById(persistentClass, id); > } > > } > > And this is how I use the generic class: > > GenericDAOApacheOJB<GrandChildObject, Long> grandChildProjectDao; > grandChildProjectDao.getById(1245L); > > The project identified by the id 1245 is a GrandChildProject > (className="br.com.xxx.model.GrandChildProject"). The persistentClass > attribute points to the correct class (GrandChildProject) but somehow OJB > returns a ChildProject reference. I'm really stuck. > > One more doubt regarding mapping class hierarchy in one table. Is it > necessary to declare all subclasses of Project in the extents section or > just the "direct subclass"? > Ex: > <class-descriptor table="PROJECT_TABLE" class="br.com.xxx.model.Project"> > <extent-class class-ref="br.com.xxx.model.ChildProject" /> > > or > > <class-descriptor table="PROJECT_TABLE" class="br.com.xxx.model.Project"> > <extent-class class-ref="br.com.xxx.model.ChildProject" /> > <extent-class class-ref="br.com.xxx.model.GrandChildProject" /> > > Thanks in advance! > > -- > View this message in context: > http://www.nabble.com/Mapping-hierarchy-in-one-table-problem-tp15354434p15409604.html > Sent from the Apache DB - ObjectRelationalBridge Users mailing list > archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >