1 Reply Latest reply on Jun 1, 2006 8:44 AM by doubledenim

    eager fetching problem.

    doubledenim

      This is different to my previous post on eager fetching.


      Within my entity manager class i have the following..

      List<AffiliateCommission> affiliateCommissions = session.getAffiliate().getAffiliateCommissions();
      ListIterator<AffiliateCommission> affiliateCommissionIterator = affiliateCommissions.listIterator();
      while(affiliateCommissionIterator.hasNext())
      {
       AffiliateCommission affiliateCommission = affiliateCommissionIterator.next();
      
      


      My Affiliate class has a OneToMany relationship with AffiliateCommission using the following code.

      @OneToMany(mappedBy="affiliate")
      @IndexColumn(name="affiliate_commission_id")
      public java.util.List<AffiliateCommission> getAffiliateCommissions() {
       return affiliateCommissions;
      }
      


      The AffiliateCommission object has a bunch of other entities as its properties that are set to fetch type eager.

      In my database there are two affiliate_commission rows that relate to the affiliate object I am referring to in the top bit of code.
      However when i use session.getAffiliate().getAffiliateCommissions() I get 3 elements populated in my list, the first one being null.

      I cannot figure out why. Before, when i wasn't using @IndexColumn (in a previous release of JBoss AS) i had the @OneToMany set to FetchType.Eager, this worked fine.

      I have also checked the mysql logs, and pasted the same select query into mysql query browser and it only produced two records.

      Is this a bug? or an issue with the IndexColumn annotation?

      THX dan