Hi, Gary:
Thank you for the detailed explanation, what I
intended to do is slightly different from your setup.
It's like this (just to show the idea, code not
checked):
/**
* Layer super type
*/
public abstract class BaseBO
{
/**
* @ojb.field column="n_id"
*/
protected int id;
...
}
/**
* Concrete class
* @ojb.class table="t_test"
*/
public class TestBO
extends BaseBO
{
/**
* @ojb.field column="v_name"
*/
protected String name;
...
}
BaseBO is a layer super type for all business objects,
and I don't want a class descriptor for it in the
repository file, but I do need the id field in
concrete classes, i.e. TestBO. I don't think BaseBO's
presence in the repository.xml will cause problems,
but just to be neat I'd like it out of the mapping.
The document for ojb xdoclet explicitly states that
this is possible ("Note that the base type containing
the fields/references/collections is not required to
have the ojb.class tag.").
Setup this thing is harder than I thought, especially
the torque part, took me nearly a day to get
everything in place.
--- Gary Richards <[EMAIL PROTECTED]> wrote:
> 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
>
=== message truncated ===
__________________________________
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]