How to save an object with null dbref in mongodb java spring? -


I am looking for a solution to save an object with a blank debrief in the Mongload Java Spring Framework. Consider the following example:

  @documents public class A {@Id personal string id; @dbrf private bb; Public A () {this.b = null; } ...} @document public class b {@ id personal string id; }  

Now if I have one, i.e a = new A (); and I save this object to mongoode via the repository, i.e. aRepo.save (a) . After that, I have the following exception:

  org.springframework.data.mapping.model.MappingException: No reference can be made with a tap id with an object. Can anyone save an object from empty debrief?  

Thank you for your help!

In the form you can create NullObject such as:

  public final Static B NULL_B = New B ("");  

and use it instead of blank

  public A () {this.b = NULL_B; }  

Comments