How to convert a select statement in mysql into a query in java?

Viewed 69

I have a select statement inside MySQL.

select * from tbl_user where path like '%,id,%'

How can I convert it to a query in Java? What I want to pass id.

2 Answers

maybe

@Query(value = "select * from tbl_user where path like CONCAT('%,',?1,',%')", nativeQuery = true) 
Iterable<Tbl_user> findAllChildUsers(int id);

will help

It depends of what framework/library are you using. in hibernate you can use :id, but you have to also check that it is native query.

In some libraries you just pass a String as a query.

Related