I seem to be having an issue with Lazy loading. I am using the latest Spring and the latest OpenJPA. I have the following:
@Entity @Table(name = "category") public class Category { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; private String category; @ManyToOne private Category parentCategory; @OneToMany(mappedBy = "parentCategory", cascade = {CascadeType.ALL}, fetch = FetchType.EAGER) private Set<Category> childCategories = new HashSet<Category>(); // GETTERS AND SETTER OMITTED } If I remove the FetchType.EAGER and allow LAZY and I do the following: Category cat = (Category) getJpaTemplate().find(Category.class, id); System.out.println(cat.getChildCategories().size()); I get an NPE for getChildCategories.size(). However, with EAGER I get the 2 child records that are there. I am using the following Filter provided by Spring... <filter> <filter-name>jpaFilter</filter-name> <filter-class> org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter </filter-class> </filter> Can someone tell me what I am doing wrong? Thanks. Gregg