Git Product home page Git Product logo

demo's Introduction

📝 Notes are so important

Associations entre entités :

One to One (1:1) - Unidirectionnelle

  • Class have access: @OneToOne
  • Class have no access: nothing

One to One (1:1) - Bidirectionnelle

  • Class 1: @OneToOne
  • Class 2: @OneToOne
  • Chose one and add @MappedBy

One to Many (1:N) - Unidirectionnelle

  • Class have access (1): @OneToMany
  • Class have no access (N): nothing

One to Many (1:N) - Bidirectionnelle

  • Class have access (1): @OneToMany + List + @MappedBy
  • Class have access (N): @ManyToOne

Many to One (N:1) - Unidirectionnelle

  • Class have access (N): @ManyToOne
  • Class have no access (1): nothing

Many to One (N:1) - Bidirectionnelle

  • Class have access (N): @ManyToOne
  • Class have access (1): @OneToMany + List + @MappedBy

Many to Many (N:M) - Unidirectionnelle

  • Class have access (N): @ManyToMany + List
  • Class have no access (N): nothing

Many to Many (N:M) - Bidirectionnelle

  • Class have access (N): @ManyToMany + List
  • Class have access (N): @ManyToMany + List
  • Chose one and add @MappedBy

Annotations

  • @JsonIgnore: permet d’ignorer une propriété ou une liste de propriétés dans l’objet JSON.
  • La signification de CascadeType.ALL est que la persistance propagera (cascade) toutes les opérations EntityManager (PERSIST, REMOVE, REFRESH, MERGE, DETACH) aux entités associées. (LIST)

@Scheduled(fixedRate = 10000)

    @Scheduled(fixedRate = 10000)
    public void retrieveRendezVous() {
        Calendar cal = Calendar.getInstance();
        Date date =cal.getTime();
       rendezVousRepository.findAll().stream().filter(rendezVous1 -> rendezVous1.getDateRDZ().after(date)).forEach(rendezVous -> log.info(rendezVous.getRemarque()));
    }

Keywords

  • Afficher la liste des projets qui ont une technologie précise.
@Repository
public interface ProjetRepository extends JpaRepository<Projet, Long> {
List<Projet> findByProjetDetailTechnologieContains(String technologie);
}
  • Afficher la liste des projets d’une équipe.
@Repository
public interface ProjetRepository
        extends JpaRepository<Projet, Long> {
    List<Projet> findByEquipesIdEquipe(Long equipeId);
}
  • Afficher la liste des projets d’une équipe dont la description est non nulle.
@Repository
public interface ProjetRepository extends JpaRepository<Projet, Long> {
List<Projet>
findByEquipesIdEquipeAndProjetDetailDescriptionNotNull(Long equipeId);
}
  • Afficher la liste des projets par équipe et entreprise.
@Repository
public interface ProjetRepository extends JpaRepository<Projet, Long> {
    List<Projet> findByEquipesIdEquipeAndEquipesEntrepriseIdEntreprise(Long equipeId, Long entrepriseId);
}
  • Afficher la liste des projets par la spécialité d’une équipe et l’adresse de l’entreprise.
@Repository
public interface ProjetRepository extends JpaRepository<Projet, Long> {
    List<Projet>
    findByEquipesSpecialiteContainsAndEquipesEntrepriseAdresseContains(String specialite, String adresse);
}

JPQL

  • exemple 1: Ces méthodes permettent de récupérer les entreprises avec une adresse donnée
@Query("SELECT e FROM Entreprise e WHERE e.adresse =:adresse")
List<Entreprise> retrieveEntreprisesByAdresse(@Param("adresse") String adresse);

Si nous souhaitons faire un UPDATE, DELETE et INSERT, nous devons ajouter l’annotaion @Modifying pour activer la modification de la base de données.

  • exemple 2: Cette méthode permet de mettre à jour l’adresse de l’entreprise.
@Modifying
@Query("update Entreprise e set e.adresse = :adresse where e.idEntreprise =
:idEntreprise")
int updateEntrepriseByAdresse(@Param("adresse") String adresse,
@Param("idEntreprise")
Long idEntreprise);

Chiffre affaire entre deux date

@Query("SELECT sum (c.MontantContrat) FROM Contrat c  WHERE c.dateDebtutContrat between :startDate and :endDate and " +
            "c.dateFinContrat between :startDate and :endDate and c.archive is false and c.specialite=:specialite")
      
float getChiffreAffaireEntreDeuxDateParSpecialite(
    @Param("startDate") Date startDate,@Param("endDate")Date endDate,
    @Param("specialite") String specialite
);

URL

OpenAPI

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.