Interface ClientRepository

All Superinterfaces:
org.springframework.data.repository.CrudRepository<Client,Integer>, org.springframework.data.repository.Repository<Client,Integer>

public interface ClientRepository extends org.springframework.data.repository.CrudRepository<Client,Integer>
Repository for client entities and custom queries.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    countClientsByNameandBankerId(String clientNome, String clientCognome, Integer bankerId)
    Returns the number of clients with the same name and banker.
    Finds clients for a banker or all if bankerId is null.
    int
    updateClient(String clientName, String clientCognome, int clientId, int bankerId)
    Updates client data via native SQL.

    Methods inherited from interface org.springframework.data.repository.CrudRepository

    count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findAll, findAllById, findById, save, saveAll
  • Method Details

    • findClientsByBankerId

      @Query(value="SELECT * FROM clients c WHERE (:bankerId IS NULL OR c.id_banker = :bankerId)", nativeQuery=true) List<Client> findClientsByBankerId(Integer bankerId)
      Finds clients for a banker or all if bankerId is null.
    • countClientsByNameandBankerId

      @Query(value="SELECT COUNT(*) FROM clients c WHERE c.NOME = :clientNome AND c.COGNOME = :clientCognome AND c.ID_BANKER = :bankerId", nativeQuery=true) int countClientsByNameandBankerId(String clientNome, String clientCognome, Integer bankerId)
      Returns the number of clients with the same name and banker.
    • updateClient

      @Transactional @Modifying @Query(value="UPDATE clients SET nome=:clientName, cognome=:clientCognome, id_banker=:bankerId WHERE id=:clientId", nativeQuery=true) int updateClient(String clientName, String clientCognome, int clientId, int bankerId)
      Updates client data via native SQL.