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 Bobby Lawrence <ro...@jlab.org> on 2005/04/28 15:44:20 UTC

trouble w/ extents

Hello -
I am having some difficulty with extents - something that OJB should 
handle nicely.
I have a Project class persisted in a table called PROJECTS.
I have a Person class persisted in a table called PEOPLE.
I have a PrimaryInvestigator class that extends Person.
The PrimaryInvestigator class has some additional fields - like a 
projectId (which project they are the PI for).
The PrimaryInvestigator info that comes from a Person should still be 
stored in the PEOPLE table, but the PI-only info should be stored in a 
table called PROJECT_PI - basically a join table between PEOPLE and 
PROJECTS that looks like this:
------------
person_id
project_id

For some reason, I cannot get the mapping correctly.  Can anyone give me 
some insight as to how to write the mapping?
I tried to use:
<class-descriptor class="PrimaryInvestigator" table="PROJECT_PI" 
extends="Person">
.....
</class-descriptor>

But there really is no documentation about how to use the "extends" 
attribute.
Even so, it doesn't work for me, OJB complains about not all fields 
being set for PreparedStatement insert of Person object.

I also tried to do:
<class-descriptor class="Person" table="PEOPLE">
.....
   <extent-class class-ref=PrimaryInvestigator">
</class-descriptor>

But that doesn't quite work either - and I don't want to have to store 
the name of the object in the PEOPLE table - as described in the docs if 
you use the same table for extents.

Can anyone help?

--Bobby

-- 
----------------------------
Bobby Lawrence
MIS Application Developer

Jefferson Lab (www.jlab.org)

 Email: robertl@jlab.org
Office: (757) 269-5818
 Pager: (757) 584-5818
----------------------------





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


Re: trouble w/ extents

Posted by Armin Waibel <ar...@apache.org>.
Bobby Lawrence wrote:
> Armin -
> What is the "extends" attribute of a class-descriptor for?
> There is no documentation for this...
>

this attribute isn't used by OJB (I think this was added by a committer 
some years ago, but never worked AFAIK).

regards
Armin

> 
> Armin Waibel wrote:
> 
>> Hi Bobby,
>>
>> Bobby Lawrence wrote:
>>
>>> Hello -
>>> I am having some difficulty with extents - something that OJB should 
>>> handle nicely.
>>> I have a Project class persisted in a table called PROJECTS.
>>> I have a Person class persisted in a table called PEOPLE.
>>> I have a PrimaryInvestigator class that extends Person.
>>> The PrimaryInvestigator class has some additional fields - like a 
>>> projectId (which project they are the PI for).
>>> The PrimaryInvestigator info that comes from a Person should still be 
>>> stored in the PEOPLE table, but the PI-only info should be stored in 
>>> a table called PROJECT_PI - basically a join table between PEOPLE and 
>>> PROJECTS that looks like this:
>>> ------------
>>> person_id
>>> project_id
>>>
>>
>> So you have a m:n relation between Project and People?
>> Additionally PI has a 1:1 reference to Project (the projectId in PI)?
>>
>> To map the inheritance between People and PI you can use a 
>> "super-reference"
>> http://db.apache.org/ojb/docu/guides/advanced-technique.html#Mapping+Classes+on+Multiple+Joined+Tables 
>>
>> but there are known issues with this kind of mapping (see 
>> release-notes, try to fix this till 1.0.4).
>>
>> regards,
>> Armin
>>
>>
>>> For some reason, I cannot get the mapping correctly.  Can anyone give 
>>> me some insight as to how to write the mapping?
>>> I tried to use:
>>> <class-descriptor class="PrimaryInvestigator" table="PROJECT_PI" 
>>> extends="Person">
>>> .....
>>> </class-descriptor>
>>>
>>> But there really is no documentation about how to use the "extends" 
>>> attribute.
>>> Even so, it doesn't work for me, OJB complains about not all fields 
>>> being set for PreparedStatement insert of Person object.
>>>
>>> I also tried to do:
>>> <class-descriptor class="Person" table="PEOPLE">
>>> .....
>>>   <extent-class class-ref=PrimaryInvestigator">
>>> </class-descriptor>
>>>
>>> But that doesn't quite work either - and I don't want to have to 
>>> store the name of the object in the PEOPLE table - as described in 
>>> the docs if you use the same table for extents.
>>>
>>> Can anyone help?
>>>
>>> --Bobby
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
> 

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


Re: trouble w/ extents

Posted by Bobby Lawrence <ro...@jlab.org>.
Armin -
What is the "extends" attribute of a class-descriptor for?
There is no documentation for this...


Armin Waibel wrote:

> Hi Bobby,
>
> Bobby Lawrence wrote:
>
>> Hello -
>> I am having some difficulty with extents - something that OJB should 
>> handle nicely.
>> I have a Project class persisted in a table called PROJECTS.
>> I have a Person class persisted in a table called PEOPLE.
>> I have a PrimaryInvestigator class that extends Person.
>> The PrimaryInvestigator class has some additional fields - like a 
>> projectId (which project they are the PI for).
>> The PrimaryInvestigator info that comes from a Person should still be 
>> stored in the PEOPLE table, but the PI-only info should be stored in 
>> a table called PROJECT_PI - basically a join table between PEOPLE and 
>> PROJECTS that looks like this:
>> ------------
>> person_id
>> project_id
>>
>
> So you have a m:n relation between Project and People?
> Additionally PI has a 1:1 reference to Project (the projectId in PI)?
>
> To map the inheritance between People and PI you can use a 
> "super-reference"
> http://db.apache.org/ojb/docu/guides/advanced-technique.html#Mapping+Classes+on+Multiple+Joined+Tables 
>
> but there are known issues with this kind of mapping (see 
> release-notes, try to fix this till 1.0.4).
>
> regards,
> Armin
>
>
>> For some reason, I cannot get the mapping correctly.  Can anyone give 
>> me some insight as to how to write the mapping?
>> I tried to use:
>> <class-descriptor class="PrimaryInvestigator" table="PROJECT_PI" 
>> extends="Person">
>> .....
>> </class-descriptor>
>>
>> But there really is no documentation about how to use the "extends" 
>> attribute.
>> Even so, it doesn't work for me, OJB complains about not all fields 
>> being set for PreparedStatement insert of Person object.
>>
>> I also tried to do:
>> <class-descriptor class="Person" table="PEOPLE">
>> .....
>>   <extent-class class-ref=PrimaryInvestigator">
>> </class-descriptor>
>>
>> But that doesn't quite work either - and I don't want to have to 
>> store the name of the object in the PEOPLE table - as described in 
>> the docs if you use the same table for extents.
>>
>> Can anyone help?
>>
>> --Bobby
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>

-- 
----------------------------
Bobby Lawrence
MIS Application Developer

Jefferson Lab (www.jlab.org)

 Email: robertl@jlab.org
Office: (757) 269-5818
 Pager: (757) 584-5818
----------------------------





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


Re: trouble w/ extents

Posted by Armin Waibel <ar...@apache.org>.
Hi Bobby,

Bobby Lawrence wrote:
> Hello -
> I am having some difficulty with extents - something that OJB should 
> handle nicely.
> I have a Project class persisted in a table called PROJECTS.
> I have a Person class persisted in a table called PEOPLE.
> I have a PrimaryInvestigator class that extends Person.
> The PrimaryInvestigator class has some additional fields - like a 
> projectId (which project they are the PI for).
> The PrimaryInvestigator info that comes from a Person should still be 
> stored in the PEOPLE table, but the PI-only info should be stored in a 
> table called PROJECT_PI - basically a join table between PEOPLE and 
> PROJECTS that looks like this:
> ------------
> person_id
> project_id
> 

So you have a m:n relation between Project and People?
Additionally PI has a 1:1 reference to Project (the projectId in PI)?

To map the inheritance between People and PI you can use a "super-reference"
http://db.apache.org/ojb/docu/guides/advanced-technique.html#Mapping+Classes+on+Multiple+Joined+Tables
but there are known issues with this kind of mapping (see release-notes, 
try to fix this till 1.0.4).

regards,
Armin


> For some reason, I cannot get the mapping correctly.  Can anyone give me 
> some insight as to how to write the mapping?
> I tried to use:
> <class-descriptor class="PrimaryInvestigator" table="PROJECT_PI" 
> extends="Person">
> .....
> </class-descriptor>
> 
> But there really is no documentation about how to use the "extends" 
> attribute.
> Even so, it doesn't work for me, OJB complains about not all fields 
> being set for PreparedStatement insert of Person object.
> 
> I also tried to do:
> <class-descriptor class="Person" table="PEOPLE">
> .....
>   <extent-class class-ref=PrimaryInvestigator">
> </class-descriptor>
> 
> But that doesn't quite work either - and I don't want to have to store 
> the name of the object in the PEOPLE table - as described in the docs if 
> you use the same table for extents.
> 
> Can anyone help?
> 
> --Bobby
> 

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