-
Notifications
You must be signed in to change notification settings - Fork 364
Open
Labels
status: feedback-providedFeedback has been providedFeedback has been providedstatus: waiting-for-triageAn issue we've not yet triagedAn issue we've not yet triaged
Description
Issue Description
When creating interface projections that only expose specific fields (closed projections), omitting the entity's @Id
field can result in runtime errors during proxy creation, even when the projected fields contain valid non-null data.
Entity
@Data
@Builder
@Table("file")
public class File {
@Id
private Long id;
private String fileId;
private Long uploaderId;
private LocalDateTime uploadDate;
private String fullName;
@Builder.Default
@MappedCollection(idColumn = "file_id")
private Set<Document> documents = new HashSet<>();
}
Projection
public interface FilePreview {
String getFileId();
LocalDateTime getUploadDate();
}
Repository
public interface FileRepository extends CrudRepository<File, Long> {
List<FilePreview> findBy();
}
When invoking findBy
an java.lang.IllegalStateException
is thrown with message Identifier value must not be null at this point
.
Modifying the projection to
public interface FilePreview {
Long id;
String getFileId();
LocalDateTime getUploadDate();
}
results in the method not throwing exception.
The documentation does not mention anywhere this as an intended behaviour and it's not clear why would it be needed.
Metadata
Metadata
Assignees
Labels
status: feedback-providedFeedback has been providedFeedback has been providedstatus: waiting-for-triageAn issue we've not yet triagedAn issue we've not yet triaged