I'm trying to do a m:n mapping with non-decomposed. I have a class called applicant that references multiple program classes. But all applicant objects can reference the same program object. So if I have ten applicant objects and each applicant object references five program objects. Then out of the ten applicant objects four of them may be referencing the same program object. So when I load up an applicant object it will have a vector of program object I can access and update. But I do not want that applicant object to be able to delete or update the programs objects, because multiple applicant object may reference that same program. I just want to be able to remove the program objects from that applicant objects vector. If this makes sense can someone tell me where when I try to load x number of program objects from the database and set them in the applicant objects vector I get nothing. Right before I add the program object to the vector I try to print the programs name and it show nothing. But if I print the name right after I get them from the db the they are correct. Basically it's getting them from the database, but when I leave the scope of the method below it's like the reference if cleared out. Can someone tell me why this is. I've attached the user xml and the code that I'm using below:


public void processProgramData(java.util.Vector prog_vec, javax.servlet.http.HttpServletRequest req, java.util.Vector err) {
        if(req.getParameter(this.PROGRAMS) != null){
            if(req.getParameterValues(this.PROGRAMS).length > 0){
                String [] prog_ray = req.getParameterValues(this.PROGRAMS);
                prog_vec.clear();
                com.vu.applynow.applicant.Program program_obj = new com.vu.applynow.applicant.Program();
                for(int i=0;i < prog_ray.length;i++){
                    if(this.getProgram(prog_ray[i], program_obj)){
// If i print program_obj.getName() here it show blank, like the name variable object in the program class has been cleared
                        System.out.println("Object: " + program_obj.getName());
                        prog_vec.add(program_obj);
                    }
                }
            }
        }
    }
   
    private boolean getProgram(String id, com.vu.applynow.applicant.Program program) {
        org.odmg.Transaction tx = null;
        try{
            tx = this.odmg.newTransaction();
            tx.begin();
            org.odmg.OQLQuery query = this.odmg.newOQLQuery();
            query.create("select program from " + com.vu.applynow.applicant.Program.class.getName() + " where id = $1");
            query.bind(id);
            org.odmg.DList result = (org.odmg.DList) query.execute();
            program = (com.vu.applynow.applicant.Program) result.get(0);
            tx.commit();
// If I print program.getName() it shows............
            return true;
        }catch(org.odmg.QueryException e){
            tx.abort();
            return false;
        }catch(java.lang.IndexOutOfBoundsException e){
            tx.abort();
            return false;
        }
    }




Here's the xml........


<class-descriptor class="com.vu.applynow.applicant.Applicant" table="Applicant">    
    <field-descriptor name="id" column="id" jdbc-type="INTEGER" primarykey="true" autoincrement="true"></field-descriptor>
    <field-descriptor name="term" column="term" jdbc-type="VARCHAR"></field-descriptor>
    <field-descriptor name="term_year" column="term_year" jdbc-type="INTEGER"></field-descriptor>
    <field-descriptor name="status" column="status" jdbc-type="VARCHAR"></field-descriptor>
    <field-descriptor name="campus" column="campus" jdbc-type="VARCHAR"></field-descriptor>  
    <field-descriptor name="expelled" column="expelled" jdbc-type="BIT"></field-descriptor>  
    <field-descriptor name="probation" column="probation" jdbc-type="BIT"></field-descriptor>  
    <field-descriptor name="felony" column="felony" jdbc-type="BIT"></field-descriptor>  
    <field-descriptor name="comments" column="comments" jdbc-type="VARCHAR"></field-descriptor>
           
    <field-descriptor name="identif_id" column="identif_id" jdbc-type="INTEGER"></field-descriptor>
    <reference-descriptor name="identif" class-ref="com.vu.applynow.applicant.Identification"  auto-retrieve="true"  auto-update="true"  auto-delete="true">
    <foreignkey field-ref="identif_id"/>
    </reference-descriptor>
         
    <field-descriptor name="major_id" column="major_id" jdbc-type="INTEGER"></field-descriptor>
    <reference-descriptor name="major" class-ref="com.vu.applynow.applicant.Major"  auto-retrieve="true"  auto-update="false"  auto-delete="false">
    <foreignkey field-ref="major_id"/>
    </reference-descriptor>
         
    <field-descriptor name="guardian_id" column="guardian_id" jdbc-type="INTEGER"></field-descriptor>
    <reference-descriptor name="guardian" class-ref="com.vu.applynow.applicant.Guardian"  auto-retrieve="true"  auto-update="true"  auto-delete="true">
    <foreignkey field-ref="guardian_id"/>
    </reference-descriptor>
         
    <field-descriptor name="highschool_id" column="highschool_id" jdbc-type="INTEGER"></field-descriptor>
    <reference-descriptor name="highschool" class-ref="com.vu.applynow.applicant.HighSchool"  auto-retrieve="true"  auto-update="true"  auto-delete="true">
    <foreignkey field-ref="highschool_id"/>
    </reference-descriptor>
         
    <field-descriptor name="signature_id" column="signature_id" jdbc-type="INTEGER"></field-descriptor>
    <reference-descriptor name="signature" class-ref="com.vu.applynow.applicant.Signature"  auto-retrieve="true"  auto-update="true"  auto-delete="true">
    <foreignkey field-ref="signature_id"/>
    </reference-descriptor>
   
    <collection-descriptor name="colleges" element-class-ref="com.vu.applynow.applicant.College" orderby="id"  auto-retrieve="true"  auto-update="true"  auto-delete="true">
    <inverse-foreignkey field-ref="applicant_id"/>
    </collection-descriptor>
   
    <collection-descriptor name="dualenrolls" element-class-ref="com.vu.applynow.applicant.DualEnroll" auto-retrieve="true" auto-update="false" auto-delete="false" indirection-table="AppToDE">
    <fk-pointing-to-this-class column="applicant_id"/>
    <fk-pointing-to-element-class column="dualenroll_id"/>
    </collection-descriptor>
   
    <collection-descriptor name="goals" element-class-ref="com.vu.applynow.applicant.Goal" auto-retrieve="true" auto-update="false" auto-delete="false" indirection-table="AppToGoal">
    <fk-pointing-to-this-class column="applicant_id"/>
    <fk-pointing-to-element-class column="goal_id"/>
    </collection-descriptor>
   
    <collection-descriptor name="programs" element-class-ref="com.vu.applynow.applicant.Program" auto-retrieve="true" auto-update="false" auto-delete="false" indirection-table="AppToProgram">
    <fk-pointing-to-this-class column="applicant_id"/>
    <fk-pointing-to-element-class column="program_id"/>
    </collection-descriptor>
   
</class-descriptor>



<class-descriptor class="com.vu.applynow.applicant.Program" table="Programs">    
    <field-descriptor name="id" column="id" jdbc-type="INTEGER" primarykey="true" autoincrement="true"></field-descriptor>
    <field-descriptor name="name" column="name" jdbc-type="VARCHAR"></field-descriptor>
</class-descriptor>


Justin A. Stanczak
Web Manager
Shake Learning Resource Center
Vincennes University
(812)888-5813
Click here to talk live!
Please turn your popup blocker off to allow this function to work.

Reply via email to