playframework 2.1 - Kundera&MongoDB (in Play 2.1.3) bi-directional relationship doesn't get referenced correctly on the DB -


i'm using kundera mongo , play 2.1.3. application has user entity , document entity. user has multiple documents (onetomany) , document belongs user. first create , persist user , documents can added user. when create document , persist userid references user different userid of user entity. , user documents arraylist null.

so here's relevant parts of entities:  @entity(name="user") @table(name="user", schema="xpto@mongo") public class user {      @generatedvalue     @id     @column(name="_id")     private string userid;      @required     @column(name="name")     private string name;     (...)      @onetomany(cascade = { cascadetype.all }, fetch = fetchtype.lazy, mappedby="owner")     private list<document> documents;     (...) }   @entity(name="document") @table(name="document", schema="xpto@mongo") public class document {      @generatedvalue      @id     @column(name="_id")     private string documentid;      @required     @column(name="name")     private string name;      (...)      @manytoone(fetch = fetchtype.lazy)     @joincolumn(name="userid")     private user owner;     (...) }  --  user created , persisted. documents created afterwards following:  public static void createdocument(string name, user user) { entitymanagerfactory emf = application.getemf();     document document = new document();     document.setname(name);     ...     entitymanager em = emf.createentitymanager();     document.setowner(user);     em.persist(document);     em.close(); }  in db: db.user.find() { "_id" : "5211067576aae40da0595eb0", "name" : "name of user" (...) }  db.document.find() { "_id" : "52113c1376aae337b4537028", "name": "name", "userid" : "52113c1376aae337b4537029" }  expecting userid in document same user _id. said when try access user's documents arraylist it's null.  doing wrong here? :) in advance. 

answered on kundera-discuss group.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -