I have a OneToMany, bi-directional relationship set up with Roo/JPA. I am using the following:
Spring Roo 1.1.5.RELEASE
EclipseLink
MySQL 5.5.14
Java 1.6.0_23
Windows 7
My relationship is defined as follows:
The bi-directional relationship is defined by:Code:@RooJavaBean @RooToString public class Baby { @NotNull @ManyToOne private Mother mother; }
Any time I use a Roo finder method to fetch a Mother from the database, the set of baby objects is always null. However, fetching a Baby from the database always has the Mother member variable set correctly. I have tried FetchType.EAGER and FetchType.LAZY. For example, the following log statement always outputs zero:Code:@RooJavaBean @RooToString public class Mother{ @OneToMany(cascade = {CascadeType.REMOVE }, mappedBy = "mother", fetch = FetchType.EAGER) @OrderBy("sequence") Set<Baby> babies= new TreeSet<Baby>(); }
Thanks, any help is appreciated.Code:Mother m = Mother.findMother(id); logger.info("mother has {} children", m.getBabies().size());


Reply With Quote