Ich verwende die @ Query-Annotation, um die Abfrage im Frühjahr-Repository auszuführen. Aber ich möchte das einen Teil ändern oder eine neue Abfrage machen, entsprechend dem Zustand und übergeben im @Query („nach hier die Abfrage übergeben zu erhalten“)Übergeben Sie die dynamisch erstellte Abfrage (je nach Bedingung) in @Query Annotation
Dies ist meine Abfrage
@Query("SELECT ds.symptom FROM DoctorSymptomsModel ds where ds.doctorId = :doctorId and ds.isMostUsed = :isMostUsed)
Wenn eine Bedingung erfüllt ist, dann concat den "ORDER BY createdDate" -Teil in der Abfrage.
Oder
Kann ich die Variable machen und setzen Sie die Abfrage in dieser Variablen und setzen wie die
String query = SELECT ds.symptom FROM DoctorSymptomsModel ds where
ds.doctorId = :doctorId and ds.isMostUsed = :isMostUsed
if(result){
query = SELECT ds.symptom FROM DoctorSymptomsModel ds where ds.doctorId =
:doctorId and ds.isMostUsed = :isMostUsed ORDER BY createdDate
}
//pass the query variable here
@Query(query)
List<String> findDoctorSymptomsModelList(@Param("doctorId") long doctorId,
@Param("isMostUsed") boolean isMostUsed);