title: Spring Data Mongodb - Using @DocumentReference and @Filed at the same time
body: <p>I want to use <em>@DocumentReference</em> together with basic <em>@Field</em> annotation as two properties pointing to the same the attribute (in mongoDB) in order to easily manipulate with it. To achieve this I wrote custom lookup but the problem is, that <em>#self</em> within SpEL is null I am getting an error:</p>
  <p><strong>org.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field 'project_id' cannot be found on null</strong></p>
  <p>Code:</p>
  <pre><code>public record ProjectUser(@Id UUID id,
                        @Field(&quot;contact_email&quot;) String contactEmail,
                        @Field(&quot;phone&quot;) String phone,
                        @Field(&quot;company&quot;) String company,
                        @Field(&quot;job_title&quot;) String jobTitle,
                        @Field(&quot;note&quot;) String note,
                        @Field(&quot;parent_id&quot;) UUID parentId,
                        @Field(&quot;user_id&quot;) UUID userId,
                        @Field(&quot;project_id&quot;) UUID projectId,
                        @ReadOnlyProperty @DocumentReference(lookup = &quot;{ '_id' : '?#{#self.project_id}' }&quot;) Project project,
                        @Field(&quot;project_role_id&quot;) UUID roleId,
                        @Field(&quot;project_group_ids&quot;) List&lt;UUID&gt; projectGroupIds,
                        @Field(&quot;deleted&quot;) Boolean deleted,
                        @Field(&quot;created_date&quot;) @CreatedDate OffsetDateTime createdDate,
                        @Field(&quot;updated_date&quot;) @LastModifiedDate OffsetDateTime updatedDate) {
  
  }
  </code></pre>
  <p>Is there a way how to use both <em>@ReadOnlyProperty @DocumentReference(...) Project project</em> and <em>@Field(&quot;project_id&quot;) UUID projectId</em> at the same time? Thank you very much!!!</p>