Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edermfl/ba5cff9e0d6a2c98dbe5986c5917a3cd to your computer and use it in GitHub Desktop.
Save edermfl/ba5cff9e0d6a2c98dbe5986c5917a3cd to your computer and use it in GitHub Desktop.
public interface TimeRepository extends JpaRepository<Time, Long> {
@Query(value = "SELECT t.* FROM time t "
+ "cross JOIN boleiro_time bt, boleiro b "
+ "WHERE t.id = bt.id_time "
+ "AND bt.id_boleiro = b.id "
+ "AND b.id_usuario = ?1 "
+ "AND (t.id_gerente = ?1 "
+ " OR bt.id_boleiro IN (SELECT b2.id FROM boleiro b2 WHERE b2.id_usuario= ?1)"
+ ")", nativeQuery = true)
List<Time> findByIdUsuario(Long pIdUsuario);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment