You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Kamal Bhatt <kb...@tt.com.au> on 2006/09/21 06:44:24 UTC

Incorrect or not found field reference name

Hi
I am trying to setup a many to many relationship, where the table that 
represents the many-to-many relationship cannot be anonymous. It works 
fine when I insert a value, but when I try to update a value I get the 
following error:

Incorrect or not found field reference name 'brand_class' in descriptor 
org.apache.ojb.broker.metadata.ObjectReferenceDescriptor@1240158[cascade_retrieve=true,cascade_store=none,cascade_delete=none,is_lazy=false,class_of_Items=class 
creative.beans.BrandClass] for class-descriptor 'creative.beans.BrandParam'

Now, brand_class is a field in the database, so I don't understand what 
it is complaining about.

Here are the related tables:

CREATE TABLE brand (
    brand_id CHARACTER VARYING(8) NOT NULL,
    brand_name CHARACTER VARYING NOT NULL,
    is_bookable BOOLEAN DEFAULT 'true' NOT NULL,
    agency_code CHARACTER VARYING(8),
    consultant_id CHARACTER VARYING(5),
    webbook_locn CHARACTER VARYING,
    is_white_label BOOLEAN DEFAULT 'true' NOT NULL,
    logo CHARACTER VARYING,
    colour_1 CHARACTER VARYING(6),
    colour_2 CHARACTER VARYING(6),
    enquiry_text CHARACTER VARYING,
    extra_cond CHARACTER VARYING,
    extra_info CHARACTER VARYING,
    contact_details CHARACTER VARYING,
    to_email_addr CHARACTER VARYING,
    from_email_addr CHARACTER VARYING,
    cc_email_addr CHARACTER VARYING,
    PRIMARY KEY (brand_id)
);

CREATE TABLE extra_enq_field (
    id SERIAL NOT NULL,
    brand CHARACTER VARYING(8) NOT NULL,
    label CHARACTER VARYING(15) NOT NULL,
    display_type CHARACTER VARYING(15) NOT NULL,
    PRIMARY KEY (id)
);

CREATE TABLE brand_class (
    id SERIAL NOT NULL,
    label VARCHAR(20) NOT NULL,
    is_required BOOLEAN DEFAULT 'false' NOT NULL,
    PRIMARY KEY(id)
);   

CREATE TABLE brand_param (
    brand VARCHAR(8) NOT NULL,
    brand_class integer NOT NULL,
    value VARCHAR,
    PRIMARY KEY(brand, brand_class)
);

I have created classes for all these functions. I will include 
BrandParam and BrandClass:

public class BrandParam implements Serializable
{

    public BrandParam()
    {
    }  

    public BrandParam(BrandClass inBrandClass)
    {
    mBrandClass = inBrandClass;
    mId = inBrandClass.getId();
    }   

    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
    /** Obtain the value.                                                
    */
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/

    public String getValue() { return(mValue); }

    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
    /** Obtain the brand class.                                        
            */
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/

    public BrandClass getBrandClass() { return(mBrandClass); }

    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
    /** Wrapper for mBrandClass.getLabel.                                
            */
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/

    public String getLabel() { return(mBrandClass.getLabel()); }

    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
    /** Wrapper for mBrandClass.isRequired.                            
                */
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/

    public boolean getIsRequired() { return(mBrandClass.getIsRequired()); }

    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
    /** Wrapper for mBrandClass.getId.                                
                */
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/

    public int getId() { return(mId); }
   
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
    /** Set value.                                                        */
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
  
    public void setValue(String inValue) { mValue = inValue; }

    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
    /** Set BrandClass.                                                
        */
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
  
    public void setBrandClass(BrandClass inBrandClass) { mBrandClass = 
inBrandClass; }

    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
    /** Wrapper for mBrandClass.setLabel.                                
            */
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
  
    public void setLabel(String inLabel) { mBrandClass.setLabel(inLabel); }
   
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
    /** Wrapper for mBrandClass.setRequired.                            
                */
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
  
    public void setIsRequired(boolean inIsRequired) { 
mBrandClass.setIsRequired(inIsRequired); }
   
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
    /** set Id.                                                        
    */
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
  
    public void setId(int inId) { mId = inId;  }
   
    /* 
========================================================================================================================= 
*/
    /* PRIVATE MEMBERS                                                
         */
    /* 
========================================================================================================================= 
*/
  
    private int        mId;    // Required for OJB binding
    private String    mValue;
    private BrandClass    mBrandClass;
}

public class BrandParam implements Serializable
{

    public BrandParam()
    {
    }  

    public BrandParam(BrandClass inBrandClass)
    {
    mBrandClass = inBrandClass;
    mId = inBrandClass.getId();
    }   

    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
    /** Obtain the value.                                                
    */
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/

    public String getValue() { return(mValue); }

    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
    /** Obtain the brand class.                                        
            */
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/

    public BrandClass getBrandClass() { return(mBrandClass); }

    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
    /** Wrapper for mBrandClass.getLabel.                                
            */
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/

    public String getLabel() { return(mBrandClass.getLabel()); }

    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
    /** Wrapper for mBrandClass.isRequired.                            
                */
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/

    public boolean getIsRequired() { return(mBrandClass.getIsRequired()); }

    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
    /** Wrapper for mBrandClass.getId.                                
                */
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/

    public int getId() { return(mId); }
   
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
    /** Set value.                                                        */
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
  
    public void setValue(String inValue) { mValue = inValue; }

    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
    /** Set BrandClass.                                                
        */
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
  
    public void setBrandClass(BrandClass inBrandClass) { mBrandClass = 
inBrandClass; }

    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
    /** Wrapper for mBrandClass.setLabel.                                
            */
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
  
    public void setLabel(String inLabel) { mBrandClass.setLabel(inLabel); }
   
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
    /** Wrapper for mBrandClass.setRequired.                            
                */
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
  
    public void setIsRequired(boolean inIsRequired) { 
mBrandClass.setIsRequired(inIsRequired); }
   
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
    /** set Id.                                                        
    */
    /* 
------------------------------------------------------------------------------------------------------------------------ 
*/
  
    public void setId(int inId) { mId = inId;  }
   
    /* 
========================================================================================================================= 
*/
    /* PRIVATE MEMBERS                                                
         */
    /* 
========================================================================================================================= 
*/
  
    private int        mId;    // Required for OJB binding
    private String    mValue;
    private BrandClass    mBrandClass;
}

Here are the relevant mappings:
    <class-descriptor class="creative.beans.Brand" table="brand">
        <field-descriptor name="mBrandId" column="brand_id" 
jdbc-type="VARCHAR" primarykey="true"/>
    <field-descriptor name="mBrandName" column="brand_name" 
jdbc-type="VARCHAR"/>
    <field-descriptor name="mIsBookable" column="is_bookable" 
jdbc-type="BOOLEAN"/>
    <field-descriptor name="mAgencyCode" column="agency_code" 
jdbc-type="VARCHAR"/>
    <field-descriptor name="mConsultantId" column="consultant_id" 
jdbc-type="VARCHAR"/>
    <field-descriptor name="mWebbookLocn" column="webbook_locn" 
jdbc-type="VARCHAR"/>
    <field-descriptor name="mIsWhiteLabel" column="is_white_label" 
jdbc-type="BOOLEAN"/>
    <field-descriptor name="mLogo" column="logo" jdbc-type="VARCHAR"/>
    <field-descriptor name="mColour1" column="colour_1" 
jdbc-type="VARCHAR"/>
    <field-descriptor name="mColour2" column="colour_2" 
jdbc-type="VARCHAR"/>
    <field-descriptor name="mEnquiryText" column="enquiry_text" 
jdbc-type="VARCHAR"/>
    <field-descriptor name="mExtraCond" column="extra_cond" 
jdbc-type="VARCHAR"/>
    <field-descriptor name="mExtraInfo" column="extra_info" 
jdbc-type="VARCHAR"/>
    <field-descriptor name="mContactDetails" column="contact_details" 
jdbc-type="VARCHAR"/>
    <field-descriptor name="mToEmailAddr" column="to_email_addr" 
jdbc-type="VARCHAR"/>
    <field-descriptor name="mFromEmailAddr" column="from_email_addr" 
jdbc-type="VARCHAR"/>
    <field-descriptor name="mCcEmailAddr" column="cc_email_addr" 
jdbc-type="VARCHAR"/>

    <collection-descriptor name="mBrandParams" 
element-class-ref="creative.beans.BrandParam" auto-retrieve="true"
    auto-update="true" auto-delete="true">
        <inverse-foreignkey field-ref="brand"/>
    </collection-descriptor>

    <collection-descriptor name="mExtraEnqFields" 
element-class-ref="creative.beans.ExtraEnqField" auto-retrieve="true"
    auto-update="true" auto-delete="true">
        <inverse-foreignkey field-ref="brand"/>
    </collection-descriptor>   
    </class-descriptor>
   
   <class-descriptor class="creative.beans.BrandParam" table="brand_param">
        <field-descriptor name="brand" column="brand" 
jdbc-type="INTEGER" primarykey="true" default-fetch="true"
    access="anonymous"/>
    <field-descriptor name="mId" column="brand_class" 
jdbc-type="INTEGER" primarykey="true"/>
        <field-descriptor name="mValue" column="value" jdbc-type="VARCHAR"/>
    <reference-descriptor name="mBrandClass" 
class-ref="creative.beans.BrandClass" auto-update="none" auto-delete="none"
    auto-retrieve="true">
        <foreignkey field-ref="brand_class"/>
    </reference-descriptor>
    </class-descriptor>

    <class-descriptor class="creative.beans.BrandClass" table="brand_class">
        <field-descriptor name="mId" column="id" jdbc-type="INTEGER" 
primarykey="true" autoincrement="true"
    sequence-name="brand_class_id_seq"/>
    <field-descriptor name="mLabel" column="label" jdbc-type="VARCHAR"/>
    <field-descriptor name="mIsRequired" column="is_required" 
jdbc-type="BOOLEAN"/>
    </class-descriptor>

    <class-descriptor class="creative.beans.ExtraEnqField" 
table="extra_enq_field">
    <field-descriptor name="brand" column="brand" jdbc-type="VARCHAR" 
default-fetch="true" access="anonymous"/>
    <field-descriptor name="mId" column="id" jdbc-type="INTEGER"  
primarykey="true" autoincrement="true"
    sequence-name="extra_enq_field_id_seq"/>
    <field-descriptor name="mLabel" column="label" jdbc-type="VARCHAR"/>
    <field-descriptor name="mDisplayType" column="display_type" 
jdbc-type="VARCHAR"/>
    </class-descriptor>   

Any help would be appreciated.

-- 
Kamal Bhatt


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


Re: Incorrect or not found field reference name

Posted by Kamal Bhatt <kb...@tt.com.au>.
NM.

Worked it out. The reference-descriptor was pointing to the column 
heading instead of the id.

Cheers.

-- 
Kamal Bhatt


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