Spring Data REST: NULL values issue
<p>I have an implementation with Spring Data REST for a Person class and a Contract class.</p>

<p>This is my <strong>Person.class</strong>:</p>

<pre><code>@Entity
@Table
public class Person {

    @Column
    private String name;

    @Column
    private String surname;

    @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private List&lt;Contract&gt; contracts;

}
</code></pre>

<p>This is my <strong>Contract.class</strong>:</p>

<pre><code>@Entity
@Table
public class Contract {

    @Column
    private String contractType;

    @Column
    private String contractDesc;

}
</code></pre>

<p>These are my <strong>tables definitions and data</strong> (script auto-generated in an embedded HSQL DataBase):          </p>

<pre><code>CREATE MEMORY TABLE PUBLIC.PERSON(ID, NAME, SURNAME, CONTRACT_ID);
CREATE MEMORY TABLE PUBLIC.CONTRACT(ID, CONTRACTTYPE, CONTRACTDESC);
ALTER TABLE PUBLIC.PERSON ADD CONSTRAINT FK_ABCDEFGHIJKLMNOPQRSTUVWXY FOREIGN KEY(CONTRACT_ID) REFERENCES PUBLIC.CONTRACT(ID);
INSERT INTO PERSON VALUES('9876543210abcdefghijklmnopqrstuv', 'Jack', 'Reds','1234567890abcdefghijklmnopqrstuv');
INSERT INTO CONTRACT VALUES('1234567890abcdefghijklmnopqrstuv', 'OTHER', 'Other');
</code></pre>

<p>This is the <strong>response obtained</strong> from Spring Data REST, at my url:
localhost/my-app/api/persons/</p>

<pre><code>{
  "_embedded" : {
    "persons" : [ {
      "name" : "Jack",
      "surname" : "Reds",
      "contract" : {
        "contractType" : "OTHER",
        "contractDesc" : "Other",
    ...
</code></pre>

<p>But if I execute this portion of code:</p>

<pre><code>List&lt;Person&gt; persons = personRepository.findAll(new PersonSpec("TEST"));
</code></pre>

<p>in debug the variable "persons" is valorized with this data:</p>

<pre><code>persons= ArrayList&lt;E&gt; (id=233)
    elementData=Object[7] (id=235)
        [0]= Person (id=236)
            name= "Jack" (id=176)
            surname= "Reds" (id=180)
            contract= Contract_$$_jvst951_d (id=240)
                contractType= null
                contractDesc= null
        [1]= Person (id=237)
        [2]= Person (id=238)
    modCount=1
    size = 3
</code></pre>

<p>"contractType" and "contractDesc" are setted to NULL.
Furthermore, my PersonSpec seems to don't make any filtering with these fields:</p>

<pre><code>public class PersonSpec implements Specification&lt;Person&gt; {

    @Override
    public Predicate toPredicate(Root&lt;Person&gt; root, CriteriaQuery&lt;?&gt; cq, CriteriaBuilder cb) {

            if (StringUtils.isNotBlank(searchParam.getContract())) {
                predicates.add(cb.and(cb.and(cb.isNotNull(root.get("contract")),
                                             cb.isNotNull(root.get("contract").get("contractType"))),
                                       cb.equal(root.get("contract").get("contractType"), searchParam.getContract())));
            }
</code></pre>

<p>What's wrong? I don't understand why there is no link between my Person and my Contract.</p>

<p>Thanks.</p>