You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Marinschek Martin <Ma...@oekb.at> on 2004/06/23 18:04:58 UTC

Using OJB with generalization hierarchies

Hi there,

I have read through the tutorials and the mail-archive, but have not found a solution to my problem:

1) I am using the PersistenceBroker API
2) I have a generalization hierarchy: class B and C both extend A (an abstract class)
3) I map this hierarchy to one table
4) I do a 

        QueryByCriteria q = QueryFactory.newQuery(A, crit);

And want to get all instances of B and C - but get nothing...

Is there anything I am doing wrong?

- Martin 


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Using OJB with generalization hierarchies

Posted by Thomas Dudziak <to...@first.fhg.de>.
Marinschek Martin wrote:
> Hi there,
> 
> I have read through the tutorials and the mail-archive, but have not found a solution to my problem:
> 
> 1) I am using the PersistenceBroker API
> 2) I have a generalization hierarchy: class B and C both extend A (an abstract class)
> 3) I map this hierarchy to one table
> 4) I do a 
> 
>         QueryByCriteria q = QueryFactory.newQuery(A, crit);
> 
> And want to get all instances of B and C - but get nothing...

You need to tell OJB what class to instantiate. You do this by having a 
special field in all these classes (put it in A) called 'ojbConcreteClass'.
For more info see here:

http://db.apache.org/ojb/docu/advanced-technique.html#Mapping+All+Classes+on+the+Same+Table

Tom

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org