In the context of a long transaction, what is the correct way to persist an
object with a collection of children obtained from a join table?

Say, for example, I have these three tables:
STUDENT
-------
STUDENT_ID      INTEGER PK

COURSE
------
COURSE_ID               INTEGER PK

STUDENT_COURSE
--------------
STUDENT_ID              INTEGER FK
COURSE_ID               INTEGER FK

And two java objects named Student and Course, where Student has a
java.util.List collection of Course objects, which are mapped as:

<class name="Student" identity="id">
    <map-to table="STUDENT"/>
    <field name="id" type="integer">
        <sql name="STUDENT_ID" type="integer">
    </field>
    <field name="courses" type="Course" collection="collection">
        <sql name="COURSE_ID" many-table="STUDENT_COURSE"
many-key="STUDENT_ID"/>
    </field>
</class>
<class name="Course" identity="id">
    <map-to table="COURSE"/>
    <field name="id" type="integer">
        <sql name="COURSE_ID" type="integer"/>
    </field>
</class>



Then in the first transaction, a student is retrieved and sent to the UI.
The UI adds a new Course to the student object and requests the object be
saved.  Should the second transaction just have to db.update the Student
instance?

        

********************************************
Steve Ebersole
IT Integration Engineer
Vignette Corporation 
512.741.4195

Visit http://www.vignette.com

********************************************

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

Reply via email to