Sorry.
I've forgot to publish the field-descriptor for the salesPersonId:
this is the right version:

2003-10-28 11:10:45,307 ERROR [STDERR]
org.apache.ojb.broker.OJBRuntimeException: Incorrect field reference
"salesPersonId" in
[EMAIL PROTECTED]
delete=false,cascade retrieve=true,cascade store=true,is lazy=false,class of
Items=interface domain.Price]
        at
org.apache.ojb.broker.metadata.ObjectReferenceDescriptor.getForeignKeyFieldD
escriptors(Unknown Source)


I defined the following interfaces and classes:


public interface Price implements Serializable {
        public String getId();
        public Article getArticle();
        public SalesPerson getSalesPerson();
        public double getValue();
}

public class CustomerPriceImpl implements Price {
        private String id;
        private String articleId;
        private String salesPersonId;
        private double value;
        private SalesPerson salesPerson;        // 1:1 reference to Customer
        ....
        public Customer getSalesPerson() {
                return (Customer) salesPerson;
        }
        ....
}

public interface Article implements Serializable {
        public String getId();
        public String getArticleNo();
        public Collection getPrices();
}

public interface SalesPerson implements Serializable {
        public String getId();
        public String getName();
        public Collection getPrices();
}

public class CustomerImpl implements SalesPerson {
        private String id;
        private String name;
        private Collection prices = new ArrayList(); // 1:n prices
        ....
}



the mapping look like:

<!-- mapping interface Price -->
<class-descriptor class="domain.Price">
        <extent-class class-ref="domain.CustomerPriceImpl"/>
</class-descriptor>

<class-descriptor class="CustomerPriceImpl">
        <field-descriptor
                name="id"
                column="id"
                jdbc-type="VARCHAR"
                autoincrement="true"
                primarykey="true"/>
        ...
        <reference-descriptor
                name="salesPerson"
                class-ref="domain.CustomerImpl">
                <foreignkey field-ref="salesPersonId"/>
        </reference-descriptor>
</class-descriptor>

<!-- mapping interface SalesPerson -->
<class-descriptor class="domain.SalesPerson">
        <extent-class class-ref="domain.CustomerImpl"/>
        <extent-class class-ref="domain.TraderImpl"/>
</class-descriptor>

<class-descriptor class="domain.CustomerImpl">
        <field-descriptor
                name="id"
                column="id"
                jdbc-type="VARCHAR"
                autoincrement="true"
                primarykey="true"/>

        <field-descriptor
                name="salesPersonId"
                column="customer_Id"
                jdbc-type="VARCHAR"/>
        ....
        <collection-descriptor
        name="prices"
        element-class-ref="domain.Price"
        proxy="true"
        auto-retrieve="true"
            auto-update="true">
        <inverse-foreignkey field-ref="salesPersonId"/>
     </collection-descriptor>           
</class-descriptor>

<!-- mapping interface Article -->
<class-descriptor class="domain.Article">
        <extent-class class-ref="domain.CompetitiveArticleImpl"/>
</class-descriptor>


-----Ursprüngliche Nachricht-----
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Gesendet: Dienstag, 28. Oktober 2003 12:05
An: [EMAIL PROTECTED]
Betreff: RE: Incorrect field reference


Hello,

> -----Original Message-----
> From: Reitsam Andreas [mailto:[EMAIL PROTECTED]

> 2003-10-28 11:10:45,307 ERROR [STDERR]
> org.apache.ojb.broker.OJBRuntimeException: Incorrect field reference
> "salesPersonId" in
> [EMAIL PROTECTED]
> delete=false,cascade retrieve=true,cascade store=true,is 
> lazy=false,class of
> Items=interface domain.Price]
>       at
> org.apache.ojb.broker.metadata.ObjectReferenceDescriptor.getFo
> reignKeyFieldD
> escriptors(Unknown Source)


> public class CustomerPriceImpl implements Price {
...
>       private String salesPersonId;
...
>       }
> }



> <!-- mapping interface Price -->
> <class-descriptor class="domain.Price">
>       <extent-class class-ref="domain.CustomerPriceImpl"/>
> </class-descriptor>
> 


> <class-descriptor class="domain.CustomerImpl">

>       <collection-descriptor
>               name="prices"
>               element-class-ref="domain.Price"
                               ^^^^^^^^^^^^^

you might better use domain.CustomerPriceImpl here

>               proxy="true"
>               auto-retrieve="true"
>           auto-update="true">
>         <inverse-foreignkey field-ref="salesPersonId"/>
                                        ^^^^^^^^^^^^^^^
now OJB expects domain.Price to have a field-descriptor
named salesPersonId.

>      </collection-descriptor>         
> </class-descriptor>

I think you have two ways to fix it:

1. make the type of the reference domain.CustomerPriceImpl, or

2. add a field-descriptor for salesPersonId to the 
class-descriptor of domain.Price (I know it is an interface,
but that's o.k.)

HTH,
        Olli

---------------------------------------------------------------------
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