5 Replies Latest reply on Jun 16, 2009 10:07 AM by adamw

    Prblm with associations

    pkseepat


      I am getting null values for child associations when i do forRevisionsofEntity query

      List revisionList=reader.createQuery().forRevisionsOfEntity(CurrentScheduledMaintenance.class, false, true)
      .add(AuditEntity.relatedId(�property�).eq(propertyId)).getResultList();

      The code in CurrentScheduledMaintenance.class is
      @OneToOne (fetch = FetchType.EAGER)
      @JoinColumn(name = “WORKSTREAM_ID�)
      @ForeignKey(name = “currentmaintenance_workstream_fk�)
      public Workstream getWorkstream() {
      return workstream;

      Please advise the solution

        • 1. Re: Prblm with associations
          adamw

          Well, it's not a lot of information, maybe you could expand a bit :) For example create a testcase.

          Adam

          • 2. Re: Prblm with associations
            pkseepat

            When i save a record in CURRENTMAINTENANCE object, saves a record in corresponding CURRENTMAINTENANCE_AUD TABLE (there will be no records in MaintenanceStatus_Aud table)


            IN CURRENTMAINTENANCE OBJECT I HAVE A MANYTOONE RELATION TO MAINTENANCESTATUS OBJECT
            /**
            * {@inheritDoc}
            */
            @ManyToOne(fetch = FetchType.EAGER)
            @JoinColumn(name = "maintenanceStatusId")
            @ForeignKey(name = "currentmaintenance_maintenancestatus_fk")
            public MaintenanceStatus getMaintenanceStatus() {
            return maintenanceStatus;
            }
            When I make forRevisionsOfEntity call as below
            List revisionList=reader.createQuery().forRevisionsOfEntity(CurrentScheduledMaintenance.class, false, true)
            .add(AuditEntity.relatedId("property").eq(propertyId)).getResultList();
            and when i do

            Object[] objArray = (Object[]) revisionList.get(counter);
            CurrentScheduledMaintenance csm = (CurrentScheduledMaintenance)
            objArray[0];
            csm.getMaintenanceStatus();

            is null, I am not getting association values. The above query always return null assaocation values

            • 3. Re: Prblm with associations
              pkseepat

              gets following error when i do csm.getMaintenanceStatus();

              Nested in javax.servlet.ServletException: org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [uk.co.valueworks.model.MaintenanceStatus#]:
              org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [uk.co.valueworks.model.MaintenanceStatus#]
              at org.hibernate.impl.SessionFactoryImpl$2.handleEntityNotFound(SessionFactoryImpl.java:409)
              at org.hibernate.proxy.AbstractLazyInitializer.checkTargetState(AbstractLazyInitializer.java:108)
              at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:97)
              at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:140)
              at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190)
              at uk.co.valueworks.model.MaintenanceStatus_$$_javassist_31.getMaintenanceStage(MaintenanceStatus_$$_javassist_31.java)
              at uk.co.valueworks.dao.hibernate.AddressAuditDAOHibernate.getCurrentMaintenanceRecords(AddressAuditDAOHibernate.java:268)
              at uk.co.valueworks.dao.hibernate.AddressAuditDAOHibernate.findCurrentMaintenanceByProperty(AddressAuditDAOHibernate.java:182)
              at uk.co.valueworks.service.impl.AddressAuditManagerImpl.findCurrentMaintenanceByProperty(AddressAuditManagerImpl.java:68)

              • 4. Re: Prblm with associations
                pkseepat

                is it because no record in associated maintenancestatus_aud table?

                • 5. Re: Prblm with associations
                  adamw

                  Hello,

                  I don't know why this happens. Please create a testcase and open a JIRA bug.

                  Adam