Hi Jim ,
We've only OJBDocleted a very small part of our model to date but are happy with the
current results.
The bit we have modeled is like yours, a superclass with inherited members. Presumably
you don't wan't the superclass present as a table, but you want the subclasses to have
the inherited properties in their tables.
Heres how we have it so far. Note that the superclass has an ojb.class tag but has a
generate-table-info="false" which makes sure the class is not mapped to a table.
/**
* @ojb.class generate-table-info="false"
* determine-extents="true"
* include-inherited="true"
*/
public class URL implements Serializable {
/**
* @ojb.field column="id"
* jdbc-type="INTEGER"
* primarykey="true"
* autoincrement="true"
*/
private int id;
/**
* @ojb.field column="TRAWLID"
* jdbc-type="INTEGER"
*/
private int trawlId;
/**
* @ojb.field column="URL"
* jdbc-type="VARCHAR"
* length="255"
*/
private String url = null;
/**
* @ojb.class table="STARTINGURL"
* determine-extents="false"
* include-inherited="true"
*/
public class StartingUrl extends URL {
// no properties specific to this class yet.
This is the generated repository_user.xml,
<!-- file containing the repository descriptions for user-defined types -->
<!-- Generated by the xdoclet-ojb module -->
<class-descriptor
class="uk.co.magus.trawl.URL"
>
<extent-class class-ref="uk.co.magus.trawl.CachedUrl"/>
<extent-class class-ref="uk.co.magus.trawl.StartingUrl"/>
</class-descriptor>
<class-descriptor
class="uk.co.magus.trawl.StartingUrl"
table="STARTINGURL"
>
<field-descriptor
name="id"
column="id"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"
>
</field-descriptor>
<field-descriptor
name="trawlId"
column="TRAWLID"
jdbc-type="INTEGER"
>
</field-descriptor>
<field-descriptor
name="url"
column="URL"
jdbc-type="VARCHAR"
length="255"
>
</field-descriptor>
</class-descriptor>
<class-descriptor
class="uk.co.magus.trawl.Trawl"
table="TRAWL"
>
<field-descriptor
name="id"
column="id"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"
>
</field-descriptor>
<field-descriptor
name="name"
column="NAME"
jdbc-type="VARCHAR"
>
</field-descriptor>
<collection-descriptor
name="startingURLs"
element-class-ref="uk.co.magus.trawl.URL"
auto-retrieve="true"
auto-update="false"
auto-delete="false"
>
<inverse-foreignkey field-ref="trawlId"/>
</collection-descriptor>
</class-descriptor>
Setting up the build was more of a challenge. We found that simply dropping the
modules into a current xdoclet 1.2b2 installation was a bad idea. I remember some
error messages about ifHasMemberWithTag on line 10 of intermediate-representation.xdt.
Running the downloaded ojbdoclet jars as their own xdoclet distribution (ie, only
having xdoclet-1.2b3-dev.jar, xdoclet-ojb-module-1.2b3-dev.jar,
xjavadoc-1.0-SNAPSHOT.jar) made that go away. Unfortunatley that means we have 2
xdoclet distributions used by our build script at the moment, a proper xdoclet 1.2b2
version and an ojbdoclet minimal version. I get the impression this little method of
building will no longer be necessary when the ojbdoclet bits become part of the main
xdoclet distribution.
Hope that helps
Gary
-----Original Message-----
From: Jim JXR [mailto:[EMAIL PROTECTED]
Sent: 03 June 2003 10:45
To: [EMAIL PROTECTED]
Subject: OJB XDoclet module problem
Hi,
I wonder if anyone checked out the xdoclet module for
OJB? I tried it and it seems that there's some
problems with fields inherited from superclass.
Basically, if a field of the superclass is marked by
ojb.field tag, but the superclass itself is not marked
by ojb.class, then this field will not be included in
the subclass' class descriptor (when include-inherited
is set to true).
Is there a new version that fixes this? I decompiled
the module and did some checking. It seems that the
ifHasMemberWithTag method in class
OjbMemberTagsHandler cannot is failing, when a member
is of type XField, it uses
XDocletTagSupport.hasTag(attributes, 2) to check if
this member has the required ojb tag, but this method
does not work since
XDocletTagSupport.getCurrentField() is null. I'm no
XDoclet expert, so I have no idea what this means, but
if I set the current field of XDocletTagSupport to
member (the variable), then everything will work out.
Of course this is a hack, hopefully someone more
knowledgable will take a look at this problem and
provide an official fix.
Some other minor problems:
1. In file intermediate-representation.xdt, there're 3
extra </XDtClass:ifHasClassTag> tags that (I think)
should be removed, otherwise they were carried over to
the generated repository xml file after the above
problem is fixed.
2. In the build file, the destination file name for
torque schema should be project-schema.xml, if I set
it to project_schema.xml as in the doc, torque will
refuse to generate sql file.
__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]