11 Replies Latest reply on Oct 3, 2008 8:42 PM by valatharv

    Where to make JDBC call immediately after persist

    valatharv
      How can I make JDBC call to insert a record in some other table.

      On "Save" action.. control goes to "regionHome.persist" which persists the records correctly.

      I have a bean with method say Util.insert() which handles some insertion to a table.

      Now, I want to make a JDBC call to my Util bean imediately after persist, how can I achieve this, should I override any mothod of EntityHome then call my Util...

      Please suggest

      xhtml
      <h:commandButton id="save" value="Save"
      action="#{reagentHome.persist}"
      rendered="#{!reagentHome.managed}"/>     

      reagentHome
      @Name("reagentHome")
      public class ReagentHome extends EntityHome<Reagent>
      {
          @RequestParameter
          Long reagentId;
         
          @In(required=false)
          private Long hjid;
         
          @Factory("reagent")
          public Reagent initReagent() { return getInstance(); }
         
          @Override
          public Object getId()
          {
              if (reagentId==null)
              {
                  return super.getId();
              }
              else
              {
                  return reagentId;
              }
          }
         
          @Override @Begin(join=true)
          public void create() {
              super.create();
          }   
         
          public String persist(){
              return super.persist();
          }
      }
        • 1. Re: Where to make JDBC call immediately after persist

          If you are using EntityHome<Reagent> that means you want to save using JPA/Hibernate not using plain JDBC, please read this Hibernate Tutorial first to understand how to  persiste objects using Hibernate.

          • 2. Re: Where to make JDBC call immediately after persist
            valatharv
            Thanks for replying Francisco... I am going through the tutorial.....

            I believe you can definitely help on this, this is major issue for us...

            Actually we were having issues including multiple reagents (with same field name) in a single page.
            So, we are using seam-generated reagent.xhtml which persists all mapped child elements successfully.
            As per hierarchy our entity "QuantExperiment" references "Reagent" entity and Reagent have some other child entities...
            @Entity(name = "QuantExperiment")
            protected List<Reagent> reagent;

            We have a mapping table say "QuantExp_Reagent" which have columns as (PARENT_QUANTEXPERIMENT_ID,CHILD_REAGENT_ID)

            Now, when reagent.xhtml calls reagentHome.persist it persists all mapped child elements successfully.
            For a quick solution as needed now, I need to insert a record in  mapping table "QuantExp_Reagent", I can get CHILD_REAGENT_ID from instance().getId() and will be having QuantExperimentid also....

            Basic use case;
            a) User will first see the main screen with Study, Quant Experiment and one Reagent panel.
            b) User will persists the above set on clicking save.
            c) We will provide "Add More Reagents" link on the main page itself, which will open a new window (reagent.xhtml) allowing user to fill reagent details.

            reagent.xhtml:
            ---------------
            <rich:panel>
            <f:facet name="header">Add Reagents</f:facet>
            <s:decorate id="pnameDecoration" template="layout/edit.xhtml">
                 <ui:define name="label">PName</ui:define>
                 <h:inputText id="name" required="true" immediate="true"
                                 value="#{reagentHome.instance.pname}">
                  </h:inputText>
            </s:decorate>   

            <s:decorate id="pTypeDecoration" template="layout/edit.xhtml">
                 <ui:define name="label">PType</ui:define>                         
                 <h:selectOneMenu value="#{reagentHome.instance.PType}" >
                      <f:selectItem itemValue="Control" itemLabel="Control"/>
                      <f:selectItem itemValue="Experimental" itemLabel="Experimental"/>                   
                 </h:selectOneMenu>
            </s:decorate>

            <s:decorate id="colorDecoration" template="layout/edit.xhtml">
                 <ui:define name="label">Color</ui:define>
                 <h:inputText id="name" required="true"
                                 value="#{reagentHome.instance.color}"/>
            </s:decorate>

            <s:decorate id="noteDecoration" template="layout/edit.xhtml">
                 <ui:define name="label">Note</ui:define>
                 <h:inputText id="name" required="true"
                                 value="#{reagentHome.instance.note}"/>
            </s:decorate>

            <s:decorate id="labelDecoration" template="layout/edit.xhtml">
                 <ui:define name="label">Label</ui:define>
                 <h:inputText id="name" required="true"
                                 value="#{reagentHome.instance.label}"/>
            </s:decorate>
                           
            <s:decorate id="treatmentCompDecoration" template="layout/edit.xhtml" >
                 <ui:define name="label">Treatment Compound details : </ui:define>
            </s:decorate>

            <s:decorate id="treatmentCompConcDecoration" template="layout/edit.xhtml">
                 <ui:define name="label">Concentration</ui:define>
                 <h:inputText id="name" required="false"
                                 value="#{treatmentCompoundHome.instance.treatmentConcentration}"/>
            </s:decorate>
            ........ other fields
            </rich:panel>

            <div class="actionButtons">
            <h:commandButton id="save" value="Save" action="#{reagentHome.persist}"     rendered="#{!reagentHome.managed}"/>
            ---------------------------
            ReanetHome code:
            ----------------
            public String persist(){
                 getReagent();      
                 return super.persist();
            }
            public List<Reagent> getReagent() {                      
                 List<Reagent> reagentList=new ArrayList<Reagent>();
                 Reagent reagent = (Reagent) reagentHome.initReagent();
                 reagent.setTreatment(getTreatment());
                 reagentList.add(reagent);
                 return reagentList;
            }          

            public Treatment getTreatment() {
                 Treatment treatment = treatmentHome.initTreatment();
                 List<TreatmentCompound> treatmentCompoundList = new ArrayList<TreatmentCompound>();
                 treatmentCompoundList.add(treatmentCompoundHome.initTreatmentCompound());
                 treatment.setTreatmentCompound(treatmentCompoundList);
                 treatment.setTreatmentTime(treatmentTimeHome.initTreatmentTime());
                 return treatment;
            }

            • 3. Re: Where to make JDBC call immediately after persist
              valatharv
              I need to make JDBC call immediately AFTER persist to insert a row in some table.
              Is there any mothod which I can override... or any other option...

              Please suggest how can I achieve this where in reagentHome should I call...

              My home looks like...

              @Name("reagentHome")
              public class ReagentHome extends EntityHome<Reagent>
              {
                  @RequestParameter
                  Long reagentId;
                 
                  @In(required=false)  
                  ReagentHome reagentHome;
                 
                   other home injected....

                  @In(required=false)
                  private Long hjid;
                 
                  @Factory("reagent")
                  public Reagent initReagent() { return getInstance(); }
                 
                  @Override
                  public Object getId()
                  {
                      if (reagentId==null)
                      {
                          return super.getId();
                      }
                      else
                      {
                          return reagentId;
                      }
                  }
                 
                  @Override @Begin(join=true)
                  public void create() {
                      super.create();
                  }   
                
                  public String persist(){
                       getReagent();      
                      return super.persist();
                  }
                 
                  public List<Reagent> getReagent() {                      
                       List<Reagent> reagentList=new ArrayList<Reagent>();
                       Reagent reagent = (Reagent) reagentHome.initReagent();
                       reagent.setTreatment(getTreatment());
                       reagentList.add(reagent);
                       return reagentList;
                  }
              • 4. Re: Where to make JDBC call immediately after persist

                I am sorry but I do not understand what is the question here.

                • 5. Re: Where to make JDBC call immediately after persist

                  Again: If you are using EntityHome<Reagent> that means you want to save using JPA/Hibernate not using plain JDBC. There is no need to make a JDBC call immediately AFTER persist to insert a row in some table.

                  • 6. Re: Where to make JDBC call immediately after persist
                    valatharv
                    Sorry... for the confusion... and thanks for replying, this is very important.. :(

                    JPA/Hibernate, is doing the persistence correctly... this is perfectly fine.

                    My situation is I simply want to update a table with values I have.

                    I need to call a function "insertSeparate()" in reagentHome.java this function should be called after persist() once data is COMMITTED.

                    Is there any way I can override any Entity home method... or any other option..

                    reagent.xhtml
                    <h:commandButton id="save" value="Save" action="#{reagentHome.callSave}"
                    rendered="#{!reagentHome.managed}"/>

                    reagentHome.java

                    public void callSave(){
                         persist();
                         //insertSeparate();
                    }

                    public String persist(){
                         getReagent();      
                         return super.persist();
                    }

                    //This should be called after persist() once data is commited
                    public void insertSeparate(){
                         Utils u = new Utils();
                         try {
                              u.insertIntoSeparateTable(1,instance.getHjid());
                         } catch (SQLException e) {
                              // TODO Auto-generated catch block
                              e.printStackTrace();
                         }          
                    }   
                    • 7. Re: Where to make JDBC call immediately after persist

                      Val Sw wrote on Oct 03, 2008 18:09:


                      Sorry... for the confusion... and thanks for replying, this is very important.. :(



                      JPA/Hibernate, is doing the persistence correctly... this is perfectly fine.




                      Okey, so...


                      My situation is I simply want to update a table with values I have.




                      That is exactly what hibernate is for... so, if  is doing the persistence correctly then... I do not understand what you are asking for...


                      I need to call a function "insertSeparate()" in reagentHome.java this function should be called after persist() once data is COMMITTED.




                      I hope you do not mean to say that you want to intentionally violate atomicity... Are you? You should want save all data to the database before the transaction is commited.



                      Is there any way I can override any Entity home method... or any other option..



                      I am not sure what you want... Do you want to save something else, when the persist method in the EntityHome is called, and this something else does not have @OneToMany or @ManyToOne or @ManyToMany or @OneToOne or any other relationship with what you are saving with the  persist method in the EntityHome?

                      If that is so, and what you want to save is an @Entity you could use:
                      this.getEntityManager().persist(object)
                      












                      • 8. Re: Where to make JDBC call immediately after persist

                        Val Sw wrote on Oct 03, 2008 18:09:


                        This should be called after persist() once data is commited
                        public void insertSeparate(){
                             Utils u = new Utils();
                             try {
                                  u.insertIntoSeparateTable(1,instance.getHjid());
                             } catch (SQLException e) {
                                  // TODO Auto-generated catch block
                                  e.printStackTrace();
                             }          
                        }
                        




                        Well, just call it:

                        public String persist(){
                         String persistResult = super.persist();
                         insertSeparate();//<--- CALLING IT
                         return persistResult
                        }
                        



                           


                        • 9. Re: Where to make JDBC call immediately after persist
                          valatharv
                          Here is the flow, I undestand that we are violating some atomicity but this is flow :

                          What I need is data should be committed in reagent with its id, then I want to pass this instance.getHjid() and insert a row in Join table QauntExperiment_Reagent_Join (PARENT_QUANTEXPERIMENT_ID,CHILD_REAGENT_ID), I will be getting PARENT_QUANTEXPERIMENT_ID from point (a)

                          So, it is important that Reagent is committed before I use its id.

                          a) User clicks a link say "Add Reagents" it will open reagent.xhtml, I will be passing PARENT_QUANTEXPERIMENT_ID(in a hidden field or so) while clicking the link.

                          b) User fills reagent fields in reagent.xhtml then save action will call "reagentHome.save", which calls persist() and succesfully stores reagent deatils.

                          c) Persist saves the data in reagent table with its current id which will be "instance.getHjid()"

                          d) If I call insertQuantReagent(); and pass this instance.getHjid() of reagent and try to insert in QauntExperiment_Reagent_Join it will not insert because instance.getHjid() is still not in main reagent table (transaction not committed)

                          I tried as below but not working, it hangs at "u.insertIntoQauntExpReagentJoinTable(1,instance.getHjid());" as parent Reagent id is not in main Reagent table.

                          public String persist(){
                               getReagent();      
                               //return super.persist();       
                               String persistResult = super.persist();
                               insertQuantReagent();//<--- CALLING IT
                               return persistResult;
                          }  

                          public void insertQuantReagent(){
                               System.out.println("ReagentHome.insertQuantReagent()");             
                               System.out.println("ReagentHome.insertQuantReagent(), child Reagent = "+instance.getHjid());  
                               
                               Utils u = new Utils();// Trying to create session been to update MET_QUANT_EXPERIMENT_REAGENT_J table
                               try {
                                    u.insertIntoQauntExpReagentJoinTable(1,instance.getHjid());
                               } catch (SQLException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                               }// But this should be called after persist() method
                                    
                          }   

                          public List<Reagent> getReagent() {                      
                               List<Reagent> reagentList=new ArrayList<Reagent>();
                               Reagent reagent = (Reagent) reagentHome.initReagent();
                               reagent.setTreatment(getTreatment());
                               reagentList.add(reagent);
                               return reagentList;
                          }
                          • 10. Re: Where to make JDBC call immediately after persist

                            Val Sw wrote on Oct 03, 2008 19:23:


                            Here is the flow, I undestand that we are violating some atomicity but this is flow :



                            What I need is data should be committed in reagent with its id, then I want to pass this instance.getHjid() and insert a row in Join table QauntExperimentReagentJoin (PARENTQUANTEXPERIMENTID,CHILDREAGENTID), I will be getting PARENTQUANTEXPERIMENTID from point (a)



                            So, it is important that Reagent is committed before I use its id.




                            I think you mean inserted or persisted in places where you use the word commited I really recommend you to stop doing that, it is not the proper term.


                            a) User clicks a link say Add Reagents it will open reagent.xhtml, I will be passing PARENT_QUANTEXPERIMENT_ID(in a hidden field or so) while clicking the link.




                            Ok


                            b) User fills reagent fields in reagent.xhtml then save action will call reagentHome.save, which calls persist() and succesfully stores reagent deatils.



                            Ok


                            c) Persist saves the data in reagent table with its current id which will be instance.getHjid()




                            Ok


                            d) If I call insertQuantReagent(); and pass this instance.getHjid() of reagent and try to insert in QauntExperimentReagentJoin it will not insert because instance.getHjid() is still not in main reagent table (transaction not committed)



                            I do not fully understand previous paragraph, but let me remind you that Hibernate knows how to save stuff in the proper order automatically, all you have to do is connect your @Entity objects, persist the root one, and everything will be saved in a single go, in the proper order, in a single transaction. If it is not happening that way, it means you are doing something wrong.


                            I tried as below but not working, it hangs at u.insertIntoQauntExpReagentJoinTable(1,instance.getHjid()); as parent Reagent id is not in main Reagent table.


                            public String persist(){
                                 getReagent();       
                                 //return super.persist();        
                                 String persistResult = super.persist();
                                 insertQuantReagent();//<--- CALLING IT
                                 return persistResult;
                            }   
                            
                            public void insertQuantReagent(){
                                 System.out.println("ReagentHome.insertQuantReagent()");             
                                 System.out.println("ReagentHome.insertQuantReagent(), child Reagent = "+instance.getHjid());   
                                 
                                 Utils u = new Utils();// Trying to create session been to update MET_QUANT_EXPERIMENT_REAGENT_J table
                                 try {
                                      u.insertIntoQauntExpReagentJoinTable(1,instance.getHjid());
                                 } catch (SQLException e) {
                                      // TODO Auto-generated catch block
                                      e.printStackTrace();
                                 }// But this should be called after persist() method
                                      
                            }    
                            
                            public List<Reagent> getReagent() {                      
                                 List<Reagent> reagentList=new ArrayList<Reagent>();
                                 Reagent reagent = (Reagent) reagentHome.initReagent();
                                 reagent.setTreatment(getTreatment());
                                 reagentList.add(reagent);
                                 return reagentList;
                            }
                            




                            I have no idea what Utils class has inside, but guiding myself with what you have posted before, I am almost certain it is trying to directy use JDBC to save some stuff, again, for the third time: If you are using EntityHome that means you want to save using JPA/Hibernate not using plain JDBC. There is no need to make a JDBC call immediately AFTER persist to insert a row in some table. Why do you insist on trying to do this the hard way? Ask yourself: Is there a technical reason to JDBC (like calling a stored procedure) when JPA/Hibernate can do the job in a much easier way? And then, if there is a reason, please explain that reason here.





                            • 11. Re: Where to make JDBC call immediately after persist
                              valatharv
                              I should start from scratch as it looks like I am messing up the things :( and apolozise for the mess... please suggest the way we can handle this.... it is very urgent ....

                              We have some entities all related properly and mapping is perfectly fine :
                              a) Study realated to QuantExperiment
                              @OneToMany(cascade = {CascadeType.ALL})
                              @JoinTable(name = "STUDY_QUANT_EXPERIMENT_J", joinColumns = {
                                      @JoinColumn(name = "PARENT_STUDY_ID")}, inverseJoinColumns = {
                                      @JoinColumn(name = "CHILD_QUANTEXPERIMENT_ID")})
                              @OrderBy
                                  public List<QuantExperiment> getQuantExperiment() {
                                        .....

                                   b)QuantExperiment related to Reagent
                                          @OneToMany(cascade = {CascadeType.ALL})
                                          @JoinTable(name = "QUANT_EXPERIMENT_REAGENT_J", joinColumns = {
                                          @JoinColumn(name = "PARENT_QUANTEXPERIMENT_ID")
                                          }, inverseJoinColumns = {@JoinColumn(name = "CHILD_REAGENT_ID")
                                          })
                                          @OrderBy
                                          public List<Reagent> getReagent() {
                                        ......
                                        c) Reagent realated to Treatments
                                                   @ManyToOne(cascade = {CascadeType.ALL})
                                                   @JoinColumn(name = "TREATMENT_TREATMENT_ID")
                                                   public Treatment getTreatment() {
                                                        return treatment;
                                                   }
                                                      .......
                                             d) Treatment
                                                              @OneToMany(cascade = {CascadeType.ALL})
                                                              @JoinTable(name                
                                                             = "TREAT_TREATMENT_COMPOUND_J", joinColumns = {
                                                          @JoinColumn(name = "PARENT_TREATMENT_ID")
                                                          }, inverseJoinColumns = {@JoinColumn(name 
                                                         = "CHILD_TREATMENTCOMPOUND_ID")  })
                                                        @OrderBy
                                                        public List<TreatmentCompound> getTreatmentCompound() {
                                             ....
                                                        @ManyToOne(cascade = {CascadeType.ALL})
                                                        @JoinColumn(name = "TREATMENTTIME_TREATMENTTIME__0")
                                                        public TreatmentTime getTreatmentTime() {return treatmentTime; }

                                                  e) TreatmentCompound
                                                  f) TreatmentTime

                              Now, QuantExperiment can have multiple Reagents and Reagants can have multiple treatments.

                              We have a main page study.xhtml which contains form fields for Study, QuantExperiment, Reagent....
                              There is only One set of Reagent in study.xhtml which contains some reagent fields and some treatment fields.

                              When this main page study.html is submitted all values are persisted properly in main tables as well as its join table.
                              Till above it works perfectly fine.
                              refer study.xhtml and studyHome.java
                              ---------------------------------------------
                              Now, as per requirement Reagents can be multiple, which will have treatments. QuantExperiment is related to reagent.
                              a) As we cannot create multiple reagents with same name in main study.xhtml (only last will prevail), we created a link "Add More Reagents" in main study.xhtml
                              b) Add more reagents calls reagent.xhtml which calls reagentHome.save and persists itself and its child elements.
                              At this point user is creating only reagents and its child(Treatments)...

                              c) I understand your point that JPA/Hibernate should handle it correctly.

                              d) If I use quantExperimentHome to persist, doing something like "initQuantExperiment().setReagent(getReagent());"... though it persists
                              all reagents, treatments and also takes care QuantExperiment_Reagent_Join table BUT it inserts a row in main QuantExperiment table also which we don't want, is there a way we can handle this that it should not call insert on main QuantExperiment table.

                              Let me know if any code is required...

                              study.xhtml
                              -----------
                              <h:form id="studyForm">
                                   <rich:panel>
                                        <f:facet name="header">Study</f:facet>
                                        .......
                                        <s:decorate id="studyNameDecoration" template="layout/edit.xhtml">
                                             <ui:define name="label">Study Name</ui:define>
                                             <h:inputText id="name" required="true"
                                                             value="#{studyHome.instance.studyName}"/>
                                        </s:decorate>           
                                        <div style="clear:both"/>           
                                   </rich:panel>
                                   
                                   <rich:panel>
                                        <f:facet name="header">Quant Experiment</f:facet>                       
                                        
                                        <s:decorate id="entryPointDecoration" template="layout/edit.xhtml">
                                             <ui:define name="label">Entry Point</ui:define>
                                             <h:inputText id="name" required="true"
                                                             value="#{quantExperimentHome.instance.entryPoint}"/>
                                        </s:decorate>
                                    ... other quantExperiment fields
                                        
                                        <div style="clear:both"/>           
                                   </rich:panel>

                                   <rich:panel>
                                        <f:facet name="header">Reagent</f:facet> 
                                        <s:decorate id="pnameDecoration" template="layout/edit.xhtml">
                                             <ui:define name="label">PName</ui:define>
                                             <h:inputText id="name" required="true" immediate="true"
                                                             value="#{reagentHome.instance.pname}">
                                              </h:inputText>
                                        </s:decorate>   
                                        
                                        <s:decorate id="pTypeDecoration" template="layout/edit.xhtml">
                                             <ui:define name="label">PType</ui:define>                         
                                             <h:selectOneMenu value="#{reagentHome.instance.PType}" >
                                                  <f:selectItem itemValue="Control" itemLabel="Control"/>
                                                  <f:selectItem itemValue="Experimental" itemLabel="Experimental"/>                   
                                             </h:selectOneMenu>
                                        </s:decorate>
                                        
                              .... other reagent fields
                                                       
                                        <s:decorate id="treatmentCompDecoration" template="layout/edit.xhtml" >
                                             <ui:define name="label">Treatment Compound details : </ui:define>
                                        </s:decorate>
                                        
                                        <s:decorate id="treatmentCompConcDecoration" template="layout/edit.xhtml">
                                             <ui:define name="label">Concentration</ui:define>
                                             <h:inputText id="name" required="false"
                                                             value="#{treatmentCompoundHome.instance.treatmentConcentration}"/>
                                        </s:decorate>
                              ....          
                                        <s:decorate id="treatmentTimeDecoration" template="layout/edit.xhtml">
                                             <ui:define name="label">Treatment Time details : </ui:define>
                                        </s:decorate>
                                        
                                        <s:decorate id="treatmentTimeDurationDecoration" template="layout/edit.xhtml">
                                             <ui:define name="label">Time Duration</ui:define>
                                             <h:inputText id="name" required="false"
                                                             value="#{treatmentTimeHome.instance.treatmentDuration}"/>
                                        </s:decorate>
                                        <div style="clear:both"/>
                                   </rich:panel>
                                   
                                   <div class="actionButtons">
                                        <h:commandButton id="save"
                                                         value="Save"                         
                                                        action="#{studyHome.persist}"
                                                     rendered="#{!studyHome.managed}"/>                  
                              ....
                                   </div>     
                                   <!-- PASS QUANT EXPERIMENT ID, to do... -->
                                   <s:decorate id="addReagents1" template="layout/edit.xhtml">
                                             <h:outputLabel for="addReagents" value="Please create Study first, then use the link to add more reagents >>">          
                                             </h:outputLabel>
                                             <s:link target="new" view="/reagent.xhtml" value="Add More Reagents" propagation="none"/>
                                   </s:decorate>
                              </h:form>

                              studyHome.java
                              @Name("studyHome")
                              public class StudyHome extends EntityHome<Study>
                              {

                                  @RequestParameter
                                  Long studyId;
                                
                                  @In(required=false)
                                  QuantExperimentHome quantExperimentHome;
                                 
                                  @In(create=true)
                                  ReagentHome reagentHome;
                                 
                                  @In(create=true)
                                  TreatmentHome treatmentHome;
                                 
                                  @In(required=false)
                                  TreatmentCompoundHome treatmentCompoundHome;
                                 
                                  @In(required=false)
                                  TreatmentTimeHome treatmentTimeHome;
                                 
                                  @In(create=true)   
                                  ExperimentTableIndexHome experimentTableIndexHome;
                                 
                                  @In(create=true)
                                  public QuantExperiment quantExperiment;
                                 
                                  @Factory("study")
                                  public Study initStudy() { return getInstance(); }
                                 
                                  @Override
                                  public Object getId()
                                  {
                                      if (studyId==null)
                                      {
                                          return super.getId();
                                      }
                                      else
                                      {
                                          return studyId;
                                      }
                                  }
                                 
                                  @Override @Begin(nested=true)//@Begin(join=true)
                                  public void create() {
                                      super.create();
                                  }
                                 
                                  public String persist(){
                                       List<QuantExperiment> quantList = new ArrayList<QuantExperiment>();
                                       quantList.add(getQuantExperiment());
                                      initStudy().setQuantExperiment(quantList);       
                                      return super.persist();
                                  }
                                 
                                  public QuantExperiment getQuantExperiment() {
                                       QuantExperiment quantExp = quantExperimentHome.initQuantExperiment();         
                                       quantExp.setReagent(getReagent());          
                                        //Adding Experiment table details
                                        quantExp.setExperimentName(quantExperiment.getExperimentTableIndex().getExperimentName());
                                        return quantExp;
                                   }
                                 
                                  public List<Reagent> getReagent() {
                                       List<Reagent> reagentList=new ArrayList<Reagent>();
                                       Reagent reagent = reagentHome.initReagent();         
                                       reagent.setTreatment(getTreatment());
                                       reagentList.add(reagent);         
                                       return reagentList;
                                  }
                                 
                                  public Treatment getTreatment() {
                                        Treatment treatment = treatmentHome.initTreatment();
                                        List<TreatmentCompound> treatmentCompoundList = new ArrayList<TreatmentCompound>();
                                        treatmentCompoundList.add(treatmentCompoundHome.initTreatmentCompound());
                                        treatment.setTreatmentCompound(treatmentCompoundList);
                                        treatment.setTreatmentTime(treatmentTimeHome.initTreatmentTime());
                                        return treatment;
                                   }

                              quantExperimentHome
                              -------------------
                              @Name("quantExperimentHome")
                              public class QuantExperimentHome extends EntityHome<QuantExperiment>
                              {

                                  @RequestParameter
                                  Long quantExperimentId;
                                 
                                  @In(create=true)   
                                  ExperimentTableIndexHome experimentTableIndexHome;
                                 
                                  @Factory("quantExperiment")
                                  public QuantExperiment initQuantExperiment() { return getInstance(); }
                                 
                                  @Override
                                  public Object getId()
                                  {
                                      if (quantExperimentId==null)
                                      {
                                          return super.getId();
                                      }
                                      else
                                      {
                                          return quantExperimentId;
                                      }
                                  }
                                 
                                  @Override @Begin(nested=true)
                                  public void create() {
                                      super.create();
                                  }
                              }