0 Replies Latest reply on Oct 30, 2006 10:18 AM by jerryeads52

    @OneToMany not initializing

      I am creating a SEAM based application and in it I have a one to many relationship between a study and a biospecimentype. I used the DVDStore example Category, Categories and CategoriesBean as a reference. When I load a list of biospecimentypes using the following code:

       List<BiospecimenType> biospecimenTypes;
       Map<String,BiospecimenType> biospecimenTypeMap;
      
      
      @Create
       public void loadData() {
       biospecimenTypes = em.createQuery("from BiospecimenType bst")
       .setHint("org.hibernate.cacheable", true)
       .getResultList();
      
       Map<String,BiospecimenType> results = new TreeMap<String,BiospecimenType>();
      
       for (BiospecimenType biospecimenType: biospecimenTypes) {
       results.put(biospecimenType.getName(),biospecimenType);
       }
      
       biospecimenTypeMap = results;
       }
      
      


      and then try to access the list via:


       <h:selectManyListbox
       value="#{search.biospecimenTypesSelected}"
       size="10"
       converter="#{biospecimentypesbean.converter}">
       <f:selectItems value="#{biospecimentypesbean.biospecimenTypes}" />
       </h:selectManyListbox>
       <BR/><BR/><h:commandButton action="#{search.testSelected}"
       value="TestSelection"/>
       <BR/><BR/><h:outputText value="Selected Categories: "/><h:outputText value="#{search.selItemsOutput}"/>
      


      I get the following error in my JBoss server log but if I comment out the @OneToMany property in the BiospecimenType bean the list is built:

      2006-10-30 06:46:52,928 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
      2006-10-30 06:46:52,928 DEBUG [org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener] committing transaction after phase: RENDER_RESPONSE(6)
      2006-10-30 06:46:52,928 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] processing flush-time cascades
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] dirty checking collections
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.engine.Collections] Collection found: [gov.nih.nci.brn.BiospecimenType.studyCollection#1], was: [gov.nih.nci.brn.BiospecimenType.studyCollection#1] (uninitialized)
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.engine.Collections] Collection found: [gov.nih.nci.brn.BiospecimenType.studyCollection#2], was: [gov.nih.nci.brn.BiospecimenType.studyCollection#2] (uninitialized)
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.engine.Collections] Collection found: [gov.nih.nci.brn.BiospecimenType.studyCollection#3], was: [gov.nih.nci.brn.BiospecimenType.studyCollection#3] (uninitialized)
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.engine.Collections] Collection found: [gov.nih.nci.brn.BiospecimenType.studyCollection#4], was: [gov.nih.nci.brn.BiospecimenType.studyCollection#4] (uninitialized)
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.engine.Collections] Collection found: [gov.nih.nci.brn.BiospecimenType.studyCollection#5], was: [gov.nih.nci.brn.BiospecimenType.studyCollection#5] (uninitialized)
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.engine.Collections] Collection found: [gov.nih.nci.brn.BiospecimenType.studyCollection#6], was: [gov.nih.nci.brn.BiospecimenType.studyCollection#6] (uninitialized)
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.engine.Collections] Collection found: [gov.nih.nci.brn.BiospecimenType.studyCollection#7], was: [gov.nih.nci.brn.BiospecimenType.studyCollection#7] (uninitialized)
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.engine.Collections] Collection found: [gov.nih.nci.brn.BiospecimenType.studyCollection#8], was: [gov.nih.nci.brn.BiospecimenType.studyCollection#8] (uninitialized)
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.engine.Collections] Collection found: [gov.nih.nci.brn.BiospecimenType.studyCollection#9], was: [gov.nih.nci.brn.BiospecimenType.studyCollection#9] (uninitialized)
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.engine.Collections] Collection found: [gov.nih.nci.brn.BiospecimenType.studyCollection#10], was: [gov.nih.nci.brn.BiospecimenType.studyCollection#10] (uninitialized)
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.engine.Collections] Collection found: [gov.nih.nci.brn.BiospecimenType.studyCollection#11], was: [gov.nih.nci.brn.BiospecimenType.studyCollection#11] (uninitialized)
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Flushed: 0 insertions, 0 updates, 0 deletions to 11 objects
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Flushed: 0 (re)creations, 0 updates, 0 removals to 11 collections
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.pretty.Printer] listing entities:
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.pretty.Printer] gov.nih.nci.brn.BiospecimenType{createdDate=null, modifiedBy=INITIAL LOAD, modifiedDate=null, deleteRecord=null, studyCollection=, createdBy=INITIAL LOAD, name=Autopsy tissue, id=11}
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.pretty.Printer] gov.nih.nci.brn.BiospecimenType{createdDate=null, modifiedBy=INITIAL LOAD, modifiedDate=null, deleteRecord=null, studyCollection=, createdBy=INITIAL LOAD, name=Diseased Tissue, id=4}
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.pretty.Printer] gov.nih.nci.brn.BiospecimenType{createdDate=null, modifiedBy=INITIAL LOAD, modifiedDate=null, deleteRecord=null, studyCollection=, createdBy=INITIAL LOAD, name=Saliva, id=9}
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.pretty.Printer] gov.nih.nci.brn.BiospecimenType{createdDate=null, modifiedBy=INITIAL LOAD, modifiedDate=null, deleteRecord=null, studyCollection=, createdBy=INITIAL LOAD, name=Blood, id=5}
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.pretty.Printer] gov.nih.nci.brn.BiospecimenType{createdDate=null, modifiedBy=INITIAL LOAD, modifiedDate=null, deleteRecord=null, studyCollection=, createdBy=INITIAL LOAD, name=Plasma, id=7}
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.pretty.Printer] gov.nih.nci.brn.BiospecimenType{createdDate=null, modifiedBy=INITIAL LOAD, modifiedDate=null, deleteRecord=null, studyCollection=, createdBy=INITIAL LOAD, name=Malignant Tissue, id=2}
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.pretty.Printer] gov.nih.nci.brn.BiospecimenType{createdDate=null, modifiedBy=INITIAL LOAD, modifiedDate=null, deleteRecord=null, studyCollection=, createdBy=INITIAL LOAD, name=Other, id=10}
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.pretty.Printer] gov.nih.nci.brn.BiospecimenType{createdDate=null, modifiedBy=INITIAL LOAD, modifiedDate=null, deleteRecord=null, studyCollection=, createdBy=INITIAL LOAD, name=Urine, id=8}
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.pretty.Printer] gov.nih.nci.brn.BiospecimenType{createdDate=null, modifiedBy=INITIAL LOAD, modifiedDate=null, deleteRecord=null, studyCollection=, createdBy=INITIAL LOAD, name=Benign Tissue, id=3}
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.pretty.Printer] gov.nih.nci.brn.BiospecimenType{createdDate=null, modifiedBy=INITIAL LOAD, modifiedDate=null, deleteRecord=null, studyCollection=, createdBy=INITIAL LOAD, name=Serum, id=6}
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.pretty.Printer] gov.nih.nci.brn.BiospecimenType{createdDate=null, modifiedBy=INITIAL LOAD, modifiedDate=null, deleteRecord=null, studyCollection=, createdBy=INITIAL LOAD, name=Normal Tissue, id=1}
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.jdbc.JDBCContext] TransactionFactory reported no active transaction; Synchronization not registered
      2006-10-30 06:46:52,928 DEBUG [org.jboss.ejb3.entity.ManagedEntityManagerFactory] ************** closing entity managersession **************
      2006-10-30 06:46:52,928 DEBUG [org.hibernate.jdbc.JDBCContext] TransactionFactory reported no active transaction; Synchronization not registered

      The definintion for the relationship in the BiospecimenType bean is:
       @OneToMany(mappedBy="biospecimenType")
       private Set<Study> studyCollection;
      

      The definition for the relationship in the Study bean is:
       @ManyToOne
       @JoinColumn(name="BIOSPECIMEN_TYPE_ID")
       private BiospecimenType biospecimenType;
      


      Shouldn't this relationship be initialized when the biospecimentype query is run? The foreign key necessary exists and is not null for these relatiionships. I am new to SEAM and EJB3.0 so please bear with me. I am using the DALI plug-in for Eclipse to generate the entity beans and relationships.

      Thanks
      Jerry