I don't know which tag it is but the problem was discussed on this list 
about a fortnight ago so you could try the archive. It may not have been 
committed yet.

 I personally fixed the issue by insuring that the mapped types matched 
the java tyes (well, I fiddled around 'til the error went away ;-)

I make no claim for the code below other than it works for me. HTH.

from mapping.xml
 <field name="projects" type="com.fc.cookieproject.data.ProjectData" 
collection="arraylist">
      <sql many-key="clientId"/>
      <xml name="project" node="element" />
    </field>


In the relevant class I have

private List projects = new ArrayList();

public List getProjects() { return this.projects; }

public void setProjects(List proj) {this.projects = proj;}
   
public void addProject(ProjectData addMe) {
       //some code that checks for duplicates before adding to the List
}

public void removeProject(ProjectData removeMe) {
    //some code, etc.  
}

Ebersole, Steven wrote:

>You mentioned the correction for the 0.9.3.9 issue.  Do you no which tag I
>need to checkout of CVS to get that correction?
>
>It seems like a problem with the reflection code not being able to handle
>sub-types in the parameter list.  Is this what was corrected?
>
>
>
>********************************************
>Steve Ebersole
>IT Integration Engineer
>Vignette Corporation 
>512.741.4195
>
>Visit http://www.vignette.com
>
>********************************************
>
>
>-----Original Message-----
>From: Patrick van Kann [mailto:[EMAIL PROTECTED]]
>Sent: Monday, March 04, 2002 12:08 PM
>To: [EMAIL PROTECTED]
>Subject: Re: [castor-dev] Date: Fri, 1 Mar 2002 18:54:41 -0600
>
>
>In your earlier message you said you were using 0.93. Were you using 
>0.93 for the tests below? The problem you are alluding to is a known 
>problem of 0.93 and does not occur in 0.9.3.9. The problem you ran into 
>in 0.9.3.9 is also a known problem for which there are work-arounds. It 
>may even be fixed in the latest CVS.
>
>Patrick
>
>Ebersole, Steven wrote:
>
>>Thanks for the replies...
>>
>>Again, I am extremely new to Castor, so perhaps I just don't understand the
>>consequences of certain decisions we have made.  However, none of these
>>explanations seem to cover why our setup works when "pulling" a single
>>object through a query or load.  
>>
>>That being said, I went back and completely scaled-back the objects to try
>>some simple testing.  Bascially I removed everything from the mappings
>>except for Company and Location.  These are mapped as bi-directional
>>one-to-many (one Company to zero or more Locations).  All other mapping
>>elements were removed (aside from simple Java type mappings).  I removed
>>
>the
>
>>caching from both objects and removed the key generation from both objects.
>>
>>However, I am still getting the same exact issue:  when a query on company
>>returns multiple companies, all previously loaded locations are
>>
>cumulatively
>
>>added to the currently loading company.
>>
>>Below are the two class defs, mappings, and table definitions.  Please, can
>>someone tell me why Castor is unable to map this simple relationship
>>correctly?!?  Am I just missing something fundamental in the mapping?  
>>
>>Thanks in advance for any help this this...
>>
>>
>>
>>Mappings:
>>
>>   <class name="com.vignette.it.apps.jdo.CompanyImpl" identity="id">
>>       <description>Represents a Company from the COMPANY
>>table</description>
>>       <map-to table="COMPANY"/>
>>       <cache-type type="none"/>
>>       <field name="id" type="integer">
>>           <sql name="COMP_ID" type="integer"/>
>>       </field>
>>       <field name="name" type="string">
>>           <sql name="name" type="varchar"/>
>>       </field>
>>       <field name="url" type="string">
>>           <sql name="MAIN_URL" type="varchar"/>
>>       </field>
>>       <field name="locations"
>>
>type="com.vignette.it.apps.jdo.LocationImpl"
>
>>              collection="vector">
>>           <sql many-key="COMP_ID"/>
>>       </field>
>>       <field name="active" type="boolean">
>>           <sql name="active_flg"/>
>>       </field>
>>       <field name="createdDate" type="date">
>>           <sql name="CRTD_DT" type="timestamp"/>
>>       </field>
>>       <field name="modifiedDate" type="date">
>>           <sql name="CHGD_DT" type="timestamp"/>
>>       </field>
>>   </class>
>>
>>
>>   <class name="com.vignette.it.apps.jdo.LocationImpl" identity="id" >
>>       <description>A location object mapping</description>
>>       <map-to table="LOCATION"/>
>>       <cache-type type="none"/>
>>       <field name="id" type="integer">
>>           <sql name="LOC_ID" type="integer"/>
>>       </field>
>>       <field name="company" type="com.vignette.it.apps.jdo.CompanyImpl">
>>           <sql name="COMP_ID"/>
>>       </field>
>>       <field name="description" type="string">
>>           <sql name="LOC_DESC" type="varchar"/>
>>       </field>
>>       <field name="active" type="boolean">
>>           <sql name="active_flg"/>
>>       </field>
>>       <field name="createdDate" type="date">
>>           <sql name="CRTD_DT" type="timestamp"/>
>>       </field>
>>       <field name="modifiedDate" type="date">
>>           <sql name="CHGD_DT" type="timestamp"/>
>>       </field>
>>   </class>
>>
>>
>>
>>
>>
>>
>>The classes:
>>
>>public class CompanyImpl 
>>extends BaseImpl
>>implements Company
>>{
>>   private Integer id;
>>   private String name;
>>   private String url;
>>
>>   private Vector locations;
>>
>>
>>   /** Creates a new instance of Company */
>>   public CompanyImpl()
>>   {
>>       locations = new Vector();
>>   }
>>
>>   public Integer getId()
>>   {
>>       return id;
>>   }
>>
>>   public void setId( Integer id )
>>   {
>>       this.id = id;
>>   }
>>
>>   public String getName()
>>   {
>>       return name;
>>   }
>>
>>   public void setName( String name )
>>   {
>>       this.name = name;
>>   }
>>
>>   public String getUrl()
>>   {
>>       return url;
>>   }
>>
>>   public void setUrl( String url )
>>   {
>>       this.url = url;
>>   }
>>
>>   public void addLocation(LocationImpl loc)
>>   {
>>       System.out.println( "Adding location [loc_id=" + loc.getId() + 
>>               ", comp_id=" + loc.getCompany().getId() + 
>>               "] to this company [id=" + getId() + "]" );
>>//        loc.setCompany( this );
>>       locations.add( loc );
>>   }
>>
>>   public java.util.Vector getLocations()
>>   {
>>       return locations;
>>   }
>>   
>>}
>>
>>
>>
>>
>>
>>
>>
>>
>>public class LocationImpl
>>extends BaseImpl
>>implements Location
>>{
>>
>>   private Integer id;
>>   private CompanyImpl comp;
>>   private String desc;
>>
>>   /** Creates a new instance of LocationImpl */
>>   public LocationImpl()
>>   {
>>   }
>>
>>   public Integer getId()
>>   {
>>       return id;
>>   }
>>   
>>   public void setId( Integer id )
>>   {
>>       this.id = id;
>>   }
>>
>>   public String getType()
>>   {
>>       return ModelKeys.LOCATION;
>>   }
>>   
>>   public String getDescription()
>>   {
>>       return desc;
>>   }
>>   
>>   public void setDescription(String desc)
>>   {
>>       this.desc = desc;
>>   }
>>
>>   public CompanyImpl getCompany()
>>   {
>>       return comp;
>>   }
>>   
>>   public void setCompany(CompanyImpl comp)
>>   {
>>       this.comp = comp;
>>   }
>>   
>>}
>>
>>
>>
>>Table defs:
>>
>>SQL> desc company
>>Name                                      Null?    Type
>>----------------------------------------- -------- --------------
>>
>>COMP_ID                                   NOT NULL NUMBER
>>PRNT_COMP_ID                                       NUMBER
>>NAME                                               VARCHAR2(100)
>>ANNUAL_REV                                         NUMBER
>>ANNUAL_REV_CURR_ID                                 NUMBER
>>POTNL_OPP                                          NUMBER
>>POTNL_OPP_CURR_ID                                  NUMBER
>>MAIN_URL                                           VARCHAR2(250)
>>FORT_LIST_ID                                       NUMBER
>>GEO_ID                                             NUMBER
>>CUST_PROD_STAT_ID                                  NUMBER
>>BUS_OBJ                                            VARCHAR2(4000)
>>BUS_DESC                                           VARCHAR2(4000)
>>ACTIVE_FLG                                         NUMBER(1)
>>CRTD_DT                                            DATE
>>CRTD_BY                                            VARCHAR2(100)
>>CHGD_DT                                            DATE
>>CHGD_BY                                            VARCHAR2(100)
>>TERR_ID                                            NUMBER
>>PENDING_APPRVL_FLG                                 NUMBER(1)
>>
>>SQL> desc location
>>Name                                      Null?    Type
>>----------------------------------------- -------- --------------
>>
>>LOC_ID                                    NOT NULL NUMBER
>>COMP_ID                                   NOT NULL NUMBER
>>LOC_DESC                                           VARCHAR2(100)
>>ACTIVE_FLG                                         NUMBER(1)
>>CRTD_DT                                            DATE
>>CRTD_BY                                            VARCHAR2(100)
>>CHGD_DT                                            DATE
>>CHGD_BY                                            VARCHAR2(100)
>>
>>
>>
>>
>>
>>
>>
>>********************************************
>>Steve Ebersole
>>IT Integration Engineer
>>Vignette Corporation 
>>512.741.4195
>>
>>Visit http://www.vignette.com
>>
>>********************************************
>>
>>
>>-----Original Message-----
>>From: Bruce Snyder [mailto:[EMAIL PROTECTED]]
>>Sent: Sunday, March 03, 2002 1:32 AM
>>To: [EMAIL PROTECTED]
>>Subject: Re: [castor-dev] Date: Fri, 1 Mar 2002 18:54:41 -0600
>>
>>
>>This one time, at band camp, Ebersole, Steven said:
>>
>>ES>We aren't actually generating anything from our Castor setup yet.  Right
>>now
>>ES>we are only trying to get Castor to load pre-existing database rows.  So
>>the
>>ES>key generation "shouldn't" be an issue, but thanks for the heads-up;
>>
>I'll
>
>>ES>definitely keep a close eye on that when we start trying to persist.
>>
>>I think that you're missing my point here. In an earlier message
>>you stated that you were getting an exception stating that identity
>>changes were not allowed. I wonder if the key-generator is trying
>>to assign a new id to the object, hence the exception.
>>
>>ES>Another strange thing I just noticed: I have been using the jar marked
>>
>as
>
>>ES>castor.0.9.3.jar  I just tried to replace that with castor.0.9.3.9.jar
>>
>to
>
>>ES>see if it would correct any of these issues.  However, the new jar
>>complains
>>ES>about these collection joins saying it cannot find the appropriate
>>set/add
>>ES>methods.  I was using collection="collection" in the mapping for these
>>ES>joins, and then coding the object's get/set attribute as java.util.List.
>>It
>>ES>seems like that is what the new jar does not like.
>>
>>You are correct. The object types must be of java.util.Collection
>>if in the field mapping you state that the collection type is a
>>collection. I'm not aware of what may have changed between 0.9.3
>>and 0.9.3.9 to have caused this to be enforced now. I thought that
>>Castor should have been enforcing this all along.
>>
>>ES>Attached are the three classes directly invloved; please let me know if
>>you
>>ES>need to see others.  Also, I am using interfaces in front of the classes
>>for
>>ES>the UI to use.  These aren't attached.  Let me know if it would be
>>ES>beneficial to have them also.
>>
>>I didn't look at these classes much. The only other thing that I
>>can think to tell you is that Castor *only* support bi-directional
>>relationships. It does not currently provide support for uni-directional
>>relationships. For example, if A contains a relation to B, then B
>>must contain a relation to A. See the examples in src/examples/myapp
>>for more info.
>>
>>Bruce
>>--
>>
>>perl -e 'print
>>unpack("u30","<0G)U8V4\@4VYY9&5R\"F9E<G)E=\$\!F<FEI+F-O;0\`\`");'
>>
>>----------------------------------------------------------- 
>>If you wish to unsubscribe from this mailing, send mail to
>>[EMAIL PROTECTED] with a subject of:
>>      unsubscribe castor-dev
>>
>>----------------------------------------------------------- 
>>If you wish to unsubscribe from this mailing, send mail to
>>[EMAIL PROTECTED] with a subject of:
>>      unsubscribe castor-dev
>>
>
>----------------------------------------------------------- 
>If you wish to unsubscribe from this mailing, send mail to
>[EMAIL PROTECTED] with a subject of:
>       unsubscribe castor-dev
>
>----------------------------------------------------------- 
>If you wish to unsubscribe from this mailing, send mail to
>[EMAIL PROTECTED] with a subject of:
>       unsubscribe castor-dev
>

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to