I just wanted to create query dynamically.Means I just wanted to specify in which column the sorting will occure and type sorting as ASC or DESC
also with this query i have to limit the no of records. I am using the PostgreSQL here. So in the query i should specify the limit and offset .
So that i am sending the four variable in the sense attribute to the interface.
WorkflowDetailsInterface.java
@Configuration
public interface WorkflowDetailsInterface extends CrudRepository<WorkflowDetails, Integer> {
@Query(value ="SELECT workflow_id, workflow_name, workflow_description, workflow_definition, "
+ "camunda_workflow_json, camuda_deployment_id, camunda_status,diagnostic_flag, "
+ "active, del_flag FROM workflow ORDER BY :orderByColoumn : orderByOrder LIMIT :recordCountLimit OFFSET :startLimit",nativeQuery = true)
List<WorkflowDetails> listWorkflowName(@Param("startLimit") int startLimit,
@Param("recordCountLimit")int recordCountLimit,@Param("orderByColoumn")String orderByColoumn,
@Param("orderByOrder")String orderByOrder);
}
Here ,
@Param("startLimit") int startLimit
will be the starting point
@Param("recordCountLimit")int recordCountLimit
this is the offset
@Param("orderByColoumn")String orderByColoumn
order by column name
@Param("orderByOrder")String orderByOrder
order by type ASC or DESC
How can i dynamically bind these variable to my JPA query