0 Replies Latest reply on Mar 28, 2007 10:39 AM by Tobias Bergman

    Bug(?) when using @OneToMany relation, collection is not fil

    Tobias Bergman Newbie

      I have 2 entity classes:

      package testing;
      
      import javax.persistence.*;
      import java.util.List;
      
      @Entity
      @Table(name = "A")
      public class A
      {
       @Id
       @Column(name = "Id")
       private String mId;
      
       @OneToMany(mappedBy = "mA")
       private List<B> mBList;
      
       //Getter and setters to the members...
      }
      
      @Entity
      @Table(name = "B")
      public class B
      {
       @Id
       @Column(name = "Id")
       private String mId;
      
       @ManyToOne
       @JoinColumn(name = "AId")
       private A mA;
      
       //Getter and setters to the members...
      }
      


      The id column is of type uniqueidentifier and the database is MS SQL Server 2000.

      The following code prints out '0':

      A a = mEntityManager.find(A.class, "cfaae25a-761b-4430-ba0d-566ddb9bd535");
      List<B> bList = a.getBList();
      
      System.out.println(bList.size());
      


      If I have an integer as the primary key this code work without change (except for the type) and return 4 B's in the collection. But change the type to uniqueidentifier it no longer working.
      I have tried the code on glassfish and there it works with uniqueidentifier as PK type.