I have a repository and in its interface I want to create a function that requests a String and returns an object of type user, in mysql the syntax would be like this:
SELECT C.NOMBRE FROM CLIENTE C, ALIAS A WHERE A.NOMBRE = 'bar' AND A.CLIENTE_ID = C.ID
However, how would it be in the interface?
this is my class:
package app.core.repository;
import app.core.entity.Cliente;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
public interface ClienteRepository extends JpaRepository<Cliente, Integer>{
@Query("SELECT Cliente FROM CLIENTE, ALIAS A WHERE A.NOMBRE = 'bar' AND A.CLIENTE_ID = C.ID")
Cliente getClientePorAlias(@Param("alias") String alias);
}