Thomas,

Thank you.  I don't know what we'd do without your little pointers and tips.  
Everytime I browser through or contact this user list I end up smarter and 
smarter...

Thanks again,

Jeff

On Monday 03 March 2003 01:57 am, you wrote:
> Hi Jeffrey,
>
> The feature you are looking for is called cascading update.
> You store the 1-side object and want all n-side objects to be persisted
> as well.
> To do this trick slightly patch the collection descriptor:
>         <collection-descriptor
>           name="events"
>           element-class-ref="com.gilbert.Event"
>           orderby="_id"
>           sort="DESC"
>           auto-update="true"
>
>         <inverse-foreignkey field-ref="application_id"/>
>         </collection-descriptor>
>
> Please also have a closer look to tutorial3.html, section on cascading
> operations.
>
> cheers,
> Thomas
>
> Jeffrey Gilbert wrote:
> > I have the following two class files:
> >
> > package com.gilbert;
> > import java.util.Collection;
> > public class Applications {
> >     private int _id;
> >     private String name;
> >     private String description;
> >     private Collection events;  // To hold many event objects
> >
> >     public void set_id(int _id) {  this._id = _id;  }
> >     public int get_id() { return _id;  }
> >     public String getName() { return name;  }
> >     public void setName(String name) { this.name = name; }
> >     public String getDescription() { return description; }
> >     public void setDescription(String description) {
> >       this.description=description;
> >     }
> >     public Collection getEvents() { return events; }
> >     public void setEvents(Collection events) { events = events; }
> >
> >     public Applications() {
> >     }
> > }
> >
> > package com.gilbert;
> > public class Event {
> >     protected int _id;
> >     protected event;
> >     protected int application_id;
> >
> >     public void set_id(int _id) { this._id = _id; }
> >     public int get_id() { return _id; }
> >     public String getEvent() { return Event; }
> >     public void setEvent(String event) { this.event = event; }
> >     public int getApplication_id() { return application_id; }
> >     public void setApplication_id(int application_id) {
> >         this.application_id = application_id;
> >     }
> >
> >     public Event() {
> >     }
> > }
> >
> > I have the following user defined mappings:
> >
> >    <class-descriptor
> >         class="com.gilbert.Event"
> >         table="Event">
> >       <field-descriptor
> >          name="_id"
> >          column="ID"
> >          jdbc-type="INTEGER"
> >          primarykey="true"
> >          autoincrement="true"
> >       />
> >       <field-descriptor
> >          name="event"
> >          column="EVENT"
> >          jdbc-type="VARCHAR"
> >       />
> >       <field-descriptor
> >          name="application_id"
> >          column="APPLICATION_ID"
> >          jdbc-type="INTEGER"
> >          indexed="true"
> >       />
> >       </reference-descriptor>
> >     </class-descriptor>
> >
> >     <class-descriptor
> >          class="com.gilbert.Applications"
> >          table="Applications">
> >     <field-descriptor
> >          name="_id"
> >          column="ID"
> >          jdbc-type="INTEGER"
> >          primarykey="true"
> >          autoincrement="true"
> >       />
> >       <field-descriptor
> >          name="name"
> >          column="NAME"
> >          jdbc-type="VARCHAR"
> >       />
> >       <field-descriptor
> >          name="description"
> >          column="DESCRIPTION"
> >          jdbc-type="VARCHAR"
> >       />
> >        <collection-descriptor
> >          name="events"
> >          element-class-ref="com.gilbert.Event"
> >          orderby="_id"
> >          sort="DESC">
> >        <inverse-foreignkey field-ref="application_id"/>
> >        </collection-descriptor>
> >     </class-descriptor>
> >
> > Now I use the following code in my program but nothing seems to persist.
> >
> >     //Create new application object.
> >     Application application = new Application();
> >     application.setName("test1");
> >     application.setDescription("This is a test");
> >
> >     //Create new event object.
> >             Event newEvent = new Event();
> >             newEvent.setEvent("test123");
> >
> >     //Load new event object in vector
> >     Vector e = new Vector();
> >             e.add(newEvent);
> >
> >     //Add Vector that contains event into application object.
> >     application.setEvents(e);
> >
> >             // now perform persistence operations
> >             try  {
> >                 broker.beginTransaction();
> >                 broker.store(application);
> >                 broker.commitTransaction();
> >             }
> >             catch (PersistenceBrokerException pbe)
> >             {
> >                 broker.abortTransaction();
> >             }
> >
> > What am I doing wrong?  Do I need to persist the event object before I
> > persist the application object?  Is my user defined mapping file okay?
> >
> > Thanks in advance,
> >
> > Jeff
> >
> > ---------------------------------------------------------------------
> > 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