I have a spring jpa application with a "Report" entity and a "ReportRepository" which extends CrudRepository<Report, Long>.
In the ReportRepository I've implemented a method to find Reports by it's "reportNode" attribute like so:
@Data
@Builder
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@Entity
public class Report {
@Id
@GeneratedValue(strategy = AUTO)
@EqualsAndHashCode.Include
private Long id;
private Long authorId;
private Long verifyingObserverId;
private LocalDateTime creationDate;
private LocalDateTime verificationDate;
private String title;
@Lob
@Column(length=2048)
private String description;
private boolean completed;
private boolean verified;
private String joinParameter;
private String reportNode;
@Lob
@Column(length=3060)
private String hl7;
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "requested_procedure_id")
private RequestedProcedure requestedProcedure;
@OneToMany(mappedBy = "report",
cascade = CascadeType.ALL,
orphanRemoval = true)
private List<ReportVersion> reportVersions;
}
public interface ReportRepository extends CrudRepository<Report, Long> {
List<Report> findByReportNode(String reportNode);
}
When I try to use this method passing a non null parameter it works fine, returning a list of the found Reports, but, when I pass a null parameter, the method never ends it's execution.
For clarity, this works:
List<Report> pendingReports = reportRepository.findByReportNode("");
But this never returns:
List<Report> pendingReports = reportRepository.findByReportNode(null);
It doesn't throw any exception or error either.
I would like to know why this fails and how can I search all entities in a table which have a null parameter with spring jpa.
Thanks in advance
EDIT:
I've tried creating a specific method to search null values like so:
reportRepository.findByReportNodeIsNull()
But the behavior is the same. The execution hangs.