将对象属性作为参数java spring传递
我可以将属性作为参数从存储库中传递到方法中吗 例如:将对象属性作为参数java spring传递,java,spring,spring-boot,dao,Java,Spring,Spring Boot,Dao,我可以将属性作为参数从存储库中传递到方法中吗 例如: @Query("select a from Account a where :attr = :value") public Page<Account> searchByFilter(@Param("attr") String attribute,@Param("value")String value,Pageable pageable); 谢谢不,不可能 基本上,您的查询可以被编译并成功执行,但是它将被翻译成您不
@Query("select a from Account a where :attr = :value")
public Page<Account> searchByFilter(@Param("attr")
String attribute,@Param("value")String value,Pageable pageable);
谢谢不,不可能 基本上,您的查询可以被编译并成功执行,但是它将被翻译成您不喜欢的方式 最后,您将得到这样的sql
select a.* from account a where 'status' = 'Active';
注意:状态转换为字符串值,而不是列名
select a.* from account a where 'status' = 'Active';