Hi, Solved. Problem was that both sides of the bi-directional relationship were not being assigned before persisting, just one side :
user.getGroups().add(group); The following fixed the problem: user.getGroups().add(group); group.getUsers().add(user); Interesting that by restarting the app, the relationships could be read, just not after persisting. Thanks, chris > Hi, > I have a bidirectional many-to-many relationship between two > entities. Each entity references a collection of the other entity. > > I import data, then retrieve entities with a query. However, when I > refer to an entity's collection, its size is always 0 (eg, > group.getUsers().size() is 0). I look into the db and the join > table is filled correctly. I restart the app, and then the same > entity correctly returns the collection. That is, group.getUsers > ().size() is now > 0 and I can access the collection's elements. > > I am wondering is this is a known pattern and there is an a-ha out > there. Otherwise OpenJPA is working great! > > Thanks, > chris
