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]

Reply via email to