Hmmm. I tried omitting the field-descriptors from the interface
class-descriptor but it doesn't work. I get this:

java.lang.NullPointerException
        at
org.apache.ojb.broker.metadata.ClassDescriptor.getPkFields(Unknown Source)

My mapping:

    <class-descriptor class="com.microremedies.pm.persist.Account"
table="ACCOUNT" refresh="true">
        <extent-class class-ref="com.microremedies.pm.persist.AccountImpl"/>
    </class-descriptor>
    <class-descriptor class="com.microremedies.pm.persist.AccountImpl"
table="ACCOUNT" proxy="dynamic" refresh="true">
        <field-descriptor name="uid" column="uid" jdbc-type="INTEGER"
primarykey="true" autoincrement="true"/>
        <field-descriptor name="name" column="name"  jdbc-type="VARCHAR"/>
        <field-descriptor name="number" column="number"
jdbc-type="INTEGER"/>
        <field-descriptor name="typeName" column="typename"
jdbc-type="VARCHAR"/>
        <field-descriptor name="parentAccountID" column="parentAccountID"
jdbc-type="INTEGER" access="anonymous"/>
        <field-descriptor name="ojbConcreteClass" column="CLASS_NAME"
jdbc-type="VARCHAR"/>
        <reference-descriptor name="parentAccount"
class-ref="com.microremedies.pm.persist.Account">
            <foreignkey field-ref="parentAccountID"/>
        </reference-descriptor>
        <collection-descriptor name="subAccounts"
element-class-ref="com.microremedies.pm.persist.Account" auto-update="true">
            <inverse-foreignkey field-ref="parentAccountID"/>
        </collection-descriptor>
    </class-descriptor>

It does work however, if I repeat all fields, etc. in both the interface and
class descriptors.

-Ken

> -----Original Message-----
> From: Gelhar, Wallace Joseph [mailto:[EMAIL PROTECTED]
> Sent: Monday, November 17, 2003 9:38 AM
> To: OJB Users List
> Subject: RE: dynamic proxy HOWTO+
>
>
> Hi Ken,
>
> Sorry, I wasn't very specific.  You are correct in that the
> implementation class-descriptor should be declared as an extent of the
> interface class-descriptor.  The interface class-descriptor does not
> require any field attributes to be declared for it.
>
> Wally
>
> -----Original Message-----
> From: Ken Brewer [mailto:[EMAIL PROTECTED]
> Sent: Monday, November 17, 2003 8:29 AM
> To: OJB Users List; [EMAIL PROTECTED]
> Subject: RE: dynamic proxy HOWTO+
>
>
> Thanks. Do you mean that the interface should be an extent-class inside
> the implementation class-descriptor? It seems that it should be the
> other way around e.g. the implementation class would be an extent-class
> inside the interface class-descriptor?
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> > Sent: Monday, November 17, 2003 2:22 AM
> > To: OJB Users List
> > Subject: Re: dynamic proxy HOWTO+
> >
> >
> > Hi Ken,
> >
> > Ken Brewer wrote:
> > > I just started using OJB and so far so good. I'm confused about
> > the dynamic
> > > proxies. Previous to OJB, my object model used inheritance but no
> > > interfaces. Because I want lazy loading, I created an interface
> > for nearly
> > > every class. I simply named these interfaces 'I + classname'
> > e.g. Account
> > > now has an interface IAccount. I noticed that I had to change
> > my cast from
> > > the class to the interface when retrieving collection elements.
> > >
> > > 1. My application is substantially complete and has many
> > references to the
> > > class names e.g. Account. it seems I should have used the scheme
> > > Account(interface) & AccountImpl(class) in order to avoid breaking
> > > my application code references to Account, RIGHT?
> >
> > The OJB proxy mechanism provides a wrapper implementation for the
> > concrete AccountImpl. This wrapper implementation (which does the lazy
> > load) implements the interface Account.
> > So in you business object you always have to use the interface Account
>
> > to work safely with proxies. Of course it makes sense to have
> > convenient naming convention to differentiate between interfaces and
> > proxies. But OJB does not force you to any special names.
> >
> > > 2. When casting objects from a collection, should I cast to the
> > class name
> > > or proxy interface name?
> >
> > When using proxies always use the interface name. see explanation
> > above.
> >
> > > 3. Must I include the full hierarchy, including interfaces, in my
> > > repository.xml even though the interfaces are for dynamic proxies
> > > only?
> >
> > You must include at least one extent definition for the interface to
> > allow OJB to perform queries against that interface type. But you do
> > not have to declare the complete hierarchy.
> >
> > > 4. In the repository.xml, it seems that all superclass elements must
>
> > > be duplicated in each subclass? Is that correct?
> >
> > That depends on the mapping strategy. See
> > http://db.apache.org/ojb/tutorial3.html#mapping%20inheritance%20hi
> erarchies
> for details.
>
>
> cu,
> Thomas
> >
> > Thanks,
> >
> > -ken
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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]
>
>
>
> ---------------------------------------------------------------------
> 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]
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to