Entity looks like this:
@Getter
@Setter
@Entity
public class Application {
@Id
private Long id;
@Enumerated(EnumType.STRING)
private ApplicationStatus status;
}
Code works this way:
public interface ApplicationRepository extends JpaRepository<Application, Long> {
@Query("SELECT app FROM #{#entityName} AS app WHERE app.status LIKE :status")
List<Application> find(@Param("status") ApplicationStatus status);
But the same snippet with nativeQuery - doesn't:
@Query(value = "SELECT app.* FROM application AS app WHERE app.status LIKE :status", nativeQuery = true)
List<Application> findNative(@Param("status") ApplicationStatus status);
}
And I don`t have any exception, just empty list.
How can I fix this? Is it possible to use enum
with nativeQuery
?
P.S I can pass String
into method instead of ApplicationStatus
but maybe there are another option?
String
type ofstatus
parameter into method with nativeQuery instead of enumApplicationStatus
is good solution for me. – Podite