db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Taal <mt...@springsite.com>
Subject Specific User Collection Classes and get/set approach, when trying to use ojb with EMF objects
Date Tue, 05 Apr 2005 14:31:42 GMT
I am trying to use ojb to store objects generated by EMF (framework to 
generate java source code based on UML/xsd schemas, see the eclipse 
I have already covered some ground and am able to generate classes from 
a few simple xsd's (using emf), automatically generate the database 
scheme using the EMF specific javadoc tags (for all three inheritance 
mapping strategies), generate the sql files to create the database 
tables (using torque) and automatically generate ojb descriptor files to 
map from the tables to the EMF objects.

Simple 1:1 references work (storage and retrieval), in addition storing 
objects with 1:n references work.

However, retrieving an object with 1:n reference fails, because EMF 
generated java classes do not have set methods for collection members. 
Only a get method is generated (with a higher-level interface as the 
return type). EMF generates the body of the get method and there creates 
a specific List implementation which is invisible from the outside 
(therefore I can not use the collection-class attribute in the 

To get this working I have adapted the retrieveCollection method of the 
org.apache.ojb.broker.core.QueryReferenceBroker class (as a test).
In this approach I check if the get method of the member returns a valid 
List class (object) and if so call the add method on this returned List 
to fill the member.
This works for this test case but is surely not the nicest/most robust 
approach. Also I (ofcourse) do not want to have my own specific 
implementation of this ojb class.

What possibly would work better here is sort of collection factory which 
receives the class descriptor, collection descriptor and the object and 
returns an empty collection, or even handles the whole add action. This 
would also be in line with the idea of the object factory which can be 
registered from the 'outside' (which I also use to get the right EMF 
Is this possible in ojb in one way or the other or are there plans to 
add this?

Or maybe there is another better solution of which I did not think.


With Regards, Martin Taal

Barchman Wuytierslaan 72b
3818 LK Amersfoort
tel: +31 (0)33 462 02 07
fax: +31 (0)33 463 77 12
Mobile: +31 (0)6 288 48 943
email: mtaal@springsite.com
web: www.springsite.com

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

View raw message