Implementation of One-to-Many Relationships with Document References using mongodb and spring data
<p>I want to use spring data with mongodb and want to implement a one to many relationship using document reference.
db should look like this:</p>

<pre><code> {
    _id = 123451232
    "countryName":"India",
    "status":"true",
    "meetings":[123451233, 123451234]
 }

{
  _id = 123451233
   "countryName":"china",
   "status":"true"
}

{
  _id = 123451234
   "countryName":"china",
   "status":"true"
}      
</code></pre>

<p>TO achieve this i used dbRef</p>

<h2>country model</h2>

<pre><code>@Document(collection = "country")
public class Country {

    @Id
    @Field("country_id")
    private String countryId;

    @Field("country_name")
    @Indexed
    private String countryName;

    @Field("status")
    private boolean status = true;

    @DBRef
    private List&lt;Country&gt; meetings= new ArrayList&lt;Country&gt;();

    // getters and setters
</code></pre>

<p>i got an error</p>

<pre><code>HTTP Status 500 - Request processing failed; nested exception is org.springframework.data.mapping.model.MappingException: Cannot create a reference to an object with a NULL id.
</code></pre>