Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2895 connectés 

  FORUM HardWare.fr
  Programmation
  Java

  Problème de relation JAVA EE

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Problème de relation JAVA EE

n°2298047
deli2025
Posté le 21-03-2017 à 14:42:55  profilanswer
 

Bonjour,  
 
Je viens vers vous pour résoudre 2 problèmes que je rencontre actuellement.
 
Problème 1 :
 
J'essaie de récupérer toutes les categoriesThemes (Lieux, Périodes, Civilisations, Genres,...) d'une categorie (Films, Téléfilms, Documentaires,...) en rejetant une categoriesThemes précise par son ID.
 
Voici ma requête : SELECT DISTINCT c.categoriesThemes FROM Categorie c JOIN c.categoriesThemes ct WHERE c.id = :id AND ct.id <> 5
 
Mais cela ne fonction pas, je retrouve bien dans mes résultats la categoriesThemes possédant l'id N° 5...
 
Problème 2 :  
 
J'ai une entité Film, Serie, ...  Une entité User et une entité Critique
 
J'ai donc dans mes entités Film et Serie une liste de critiques avec la relation @OneToMany
 

Code :
  1. @JsonIgnore
  2. @OrderBy("id DESC" )
  3. @OneToMany
  4. private Set<Critique> critiques = new HashSet<Critique>();


 
et dans mon entité Critique j'ai la relation avec l'user  
 

Code :
  1. @OneToOne
  2. private User user;


 
Ce qui au final me donne une table Critique contenant autant les critiques de films, séries,... et ensuite une table films_critiques (ou series_critiques)  qui fait les liaisons entre les critiques et les films.
 
Je sens que cela n'est pas correcte... De plus, un utilisateur peu poster plusieurs critiques pour le même film...
 
Voici les classes entière :
 
Film :
 

Code :
  1. @Entity
  2. @Table(name="films" )
  3. public class Film extends BaseEntity
  4. {
  5. @Column(name="titre", nullable=false)
  6.     private String titre;
  7. @JsonIgnore
  8. @Column(name="titreoriginal" )
  9. private String titreOriginal;
  10.    
  11. @JsonIgnore
  12.     @Column(name="date" )
  13.     private int date;
  14.    
  15. @JsonIgnore
  16.     @Column(name="cote" )
  17.     private double cote;
  18.    
  19. @JsonIgnore
  20.     @Column(name="synopsis", columnDefinition="TEXT", nullable=false)
  21.     private String synopsis;
  22.    
  23.     @Column(name="cover" )
  24.     private String cover;
  25.    
  26.     @JsonIgnore
  27.     @Column(name="trailer" )
  28.     private String trailer;
  29.    
  30.     @JsonIgnore
  31.     @Column(name="duree" )
  32.     private String duree;
  33.    
  34.     @Column(name="alphabetique" )
  35.     private char alphabetique;
  36.    
  37.     @Column(name="url" )
  38.     private String url;
  39.    
  40.     @Column(name="wikipedia" )
  41.     private String wikipedia;
  42.    
  43.     @JsonIgnore
  44.     @Column(name="likes", nullable=false)
  45.     private int like;
  46.    
  47.     @JsonIgnore
  48.     @Column(name="dontlikes", nullable=false)
  49.     private int dontLike;
  50.    
  51.     @JsonIgnore
  52.     @OneToOne
  53.     private Public publicCible;
  54.     @JsonIgnore
  55.     @OrderBy("pays ASC" )
  56.     @ManyToMany(fetch=FetchType.LAZY)
  57.     @JoinTable(name="films_nationalites" )
  58.     private Set<Nationalite> nationalites = new HashSet<Nationalite>();
  59.    
  60.     @JsonIgnore
  61.     @OrderBy("id ASC" )
  62.     @ManyToMany(fetch=FetchType.LAZY)
  63.     @JoinTable(name="films_acteurs" )
  64.     private Set<Personne> acteurs = new HashSet<Personne>();
  65.    
  66.     @JsonIgnore
  67.     @OrderBy("id ASC" )
  68.     @ManyToMany(fetch=FetchType.LAZY)
  69.     @JoinTable(name="films_realisateurs" )
  70.     private Set<Personne> realisateurs = new HashSet<Personne>();
  71.    
  72.     @JsonIgnore
  73.     @OrderBy("id ASC" )
  74.     @ManyToMany(fetch=FetchType.LAZY)
  75.     @JoinTable(name="films_themes" )
  76.     private Set<Theme> themes = new HashSet<Theme>();
  77.    
  78.     @JsonIgnore
  79.     @OneToOne
  80.     private Categorie categorie;
  81.    
  82.     @JsonIgnore
  83.     @OrderBy("id ASC" )
  84.     @ManyToMany(fetch=FetchType.LAZY)
  85.     @JoinTable(name="films_torrents" )
  86.     private Set<Lien> torrents = new HashSet<Lien>();
  87.    
  88.     @JsonIgnore
  89.     @OrderBy("id ASC" )
  90.     @ManyToMany(fetch=FetchType.LAZY)
  91.     @JoinTable(name="films_directdownload" )
  92.     private Set<Lien> directDownload = new HashSet<Lien>();
  93.    
  94.     @JsonIgnore
  95.     @OrderBy("id ASC" )
  96.     @ManyToMany(fetch=FetchType.LAZY)
  97.     @JoinTable(name="films_streaming" )
  98.     private Set<Lien> streaming = new HashSet<Lien>();
  99.     @JsonIgnore
  100.     @OrderBy("id DESC" )
  101.     @OneToMany
  102.     private Set<Critique> critiques = new HashSet<Critique>();
  103.    
  104.     /**
  105.  *
  106.  * Constructors
  107.  */
  108.     public Film() { }
  109.    
  110.     public Film(long id, String titre, char alphabetique, String cover, String url) {
  111.      this.setTitre(titre);
  112.      this.setAlphabetique(alphabetique);
  113.      this.setCover(cover);
  114.      this.setId(id);
  115.      this.setUrl(url);
  116.     }
  117.    
  118.     public Film(long id, String titre, char alphabetique, String cover, String url, String synopsis, String duree, int date, Categorie categorie, String wikipedia) {
  119.      this.setTitre(titre);
  120.      this.setAlphabetique(alphabetique);
  121.      this.setCover(cover);
  122.      this.setId(id);
  123.      this.setUrl(url);
  124.      this.setSynopsis(synopsis);
  125.      this.setDuree(duree);
  126.      this.setDate(date);
  127.      this.setCategorie(categorie);
  128.      this.setWikipedia(wikipedia);
  129.     }
  130.        
  131.     /**
  132.  *
  133.  * Getters
  134.  */
  135.     public String getTitre()
  136.     {
  137.         return this.titre;
  138.     }
  139.    
  140.     public String getTitreOriginal()
  141.     {
  142.         return this.titreOriginal;
  143.     }
  144.    
  145.     public int getDate()
  146.     {
  147.         return this.date;
  148.     }
  149.    
  150.     public double getCote()
  151.     {
  152.         return this.cote;
  153.     }
  154.    
  155.     public String getSynopsis()
  156.     {
  157.         return this.synopsis;
  158.     }
  159.    
  160.     public String getCover()
  161.     {
  162.         return this.cover;
  163.     }
  164.    
  165.     public String getTrailer()
  166.     {
  167.         return this.trailer;
  168.     }
  169.    
  170.     public String getDuree()
  171.     {
  172.      return this.duree;
  173.     }
  174.    
  175.     public Set<Nationalite> getNationalites()
  176.     {
  177.      return this.nationalites;
  178.     }
  179.    
  180.     public Public getPublicCible()
  181.     {
  182.      return this.publicCible;
  183.     }
  184.    
  185.     public char getAlphabetique()
  186.     {
  187.      return this.alphabetique;
  188.     }
  189.    
  190.     public String getWikipedia()
  191.     {
  192.      return this.wikipedia;
  193.     }
  194.    
  195.     public String getUrl()
  196.     {
  197.      return this.url;
  198.     }
  199.    
  200.     public int getLike()
  201.     {
  202.      return this.like;
  203.     }
  204.    
  205.     public int getDontLike()
  206.     {
  207.      return this.dontLike;
  208.     }
  209.    
  210.     public Set<Personne> getActeurs()
  211.     {
  212.      return this.acteurs;
  213.     }
  214.    
  215.     public Set<Theme> getThemes()
  216.     {
  217.      return this.themes;
  218.     }
  219.    
  220.     public Set<Lien> getTorrents()
  221.     {
  222.      return this.torrents;
  223.     }
  224.    
  225.     public Set<Lien> getDirectDownload()
  226.     {
  227.      return this.directDownload;
  228.     }
  229.    
  230.     public Set<Lien> getStreaming()
  231.     {
  232.      return this.streaming;
  233.     }
  234.     public Set<Personne> getRealisateurs()
  235.     {
  236.      return this.realisateurs;
  237.     }
  238.      
  239.     public Set<Critique> getCritiques()
  240.     {
  241.      return this.critiques;
  242.     }
  243.    
  244.     public Categorie getCategorie()
  245.     {
  246.      return this.categorie;
  247.     }
  248.    
  249.     /**
  250.  *
  251.  * Setters
  252.  */
  253.     public void setTitre(String titre)
  254.     {
  255.         this.titre = titre;
  256.     }
  257.    
  258.     public void setTitreOriginal(String titreOriginal)
  259.     {
  260.         this.titreOriginal = titreOriginal;
  261.     }
  262.    
  263.     public void setDate(int date)
  264.     {
  265.         this.date = date;
  266.     }
  267.    
  268.     public void setCote(double cote)
  269.     {
  270.         this.cote = cote;
  271.     }
  272.    
  273.     public void setSynopsis(String synopsis)
  274.     {
  275.         this.synopsis = synopsis;
  276.     }
  277.    
  278.     public void setCover(String cover)
  279.     {
  280.         this.cover = cover;
  281.     }
  282.    
  283.     public void setDuree(String duree)
  284.     {
  285.      this.duree = duree;
  286.     }
  287.     public void setTrailer(String trailer)
  288.     {
  289.         this.trailer = trailer;
  290.     }
  291.    
  292.     public void setPublicCible(Public publicCible)
  293.     {
  294.      this.publicCible = publicCible;
  295.     }
  296.    
  297.     public void setAlphabetique(char alphabetique)
  298.     {
  299.      this.alphabetique = alphabetique;
  300.     }
  301.    
  302.     public void setUrl(String url)
  303.     {
  304.      this.url = url;
  305.     }
  306.    
  307.     public void setWikipedia(String wikipedia)
  308.     {
  309.      this.wikipedia = wikipedia;
  310.     }
  311.    
  312.     public void setCategorie(Categorie categorie)
  313.     {
  314.      this.categorie = categorie;
  315.     }
  316.    
  317.     /**
  318.  *
  319.  * Methods
  320.  */
  321.     public void addNationalite(Nationalite nationalite)
  322.     {
  323.         this.nationalites.add(nationalite);
  324.     }
  325.    
  326.     public void removeNationalite(Nationalite nationalite)
  327.     {
  328.         this.nationalites.remove(nationalite);
  329.     }
  330.    
  331.     public void addActeur(Personne personne)
  332.     {
  333.         this.acteurs.add(personne);
  334.     }
  335.    
  336.     public void removeActeur(Personne personne)
  337.     {
  338.         this.acteurs.remove(personne);
  339.     }
  340.    
  341.     public void addRealisateur(Personne personne)
  342.     {
  343.      this.realisateurs.add(personne);
  344.     }
  345.    
  346.     public void removeRealisateur(Personne personne)
  347.     {
  348.      this.realisateurs.remove(personne);
  349.     }
  350.    
  351.     public void addTorrent(Lien torrent)
  352.     {
  353.      this.torrents.add(torrent);
  354.     }
  355.    
  356.     public void removeTorrent(Lien torrent)
  357.     {
  358.      this.torrents.remove(torrent);
  359.     }
  360.    
  361.     public void addDirectDownload(Lien directDownload)
  362.     {
  363.      this.directDownload.add(directDownload);
  364.     }
  365.    
  366.     public void removeDirectDownload(Lien directDownload)
  367.     {
  368.      this.directDownload.remove(directDownload);
  369.     }
  370.    
  371.     public void addStreaming(Lien streaming)
  372.     {
  373.      this.streaming.add(streaming);
  374.     }
  375.    
  376.     public void removeStreaming(Lien streaming)
  377.     {
  378.      this.streaming.remove(streaming);
  379.     }
  380.    
  381.     public void addTheme(Theme theme)
  382.     {
  383.      this.themes.add(theme);
  384.     }
  385.    
  386.     public void removeTheme(Theme theme)
  387.     {
  388.      this.themes.remove(theme);
  389.     }
  390.     public void addCritique(Critique critique)
  391.     {
  392.      this.critiques.add(critique);
  393.     }
  394.    
  395.     public void removeCritique(Critique critique)
  396.     {
  397.      this.critiques.remove(critique);
  398.     }
  399.    
  400.     public void addLike()
  401.     {
  402.      this.like++;
  403.     }
  404.    
  405.     public void addDontLike()
  406.     {
  407.      this.dontLike++;
  408.     }
  409. }


 
 
Serie :
 

Code :
  1. @Entity
  2. @Table(name="series" )
  3. public class Serie extends BaseEntity
  4. {
  5. @Column(name="titre", nullable=false)
  6.     private String titre;
  7. @JsonIgnore
  8. @Column(name="titreoriginal" )
  9. private String titreOriginal;
  10.    
  11. @JsonIgnore
  12.     @Column(name="date" )
  13.     private int date;
  14.    
  15. @JsonIgnore
  16.     @Column(name="cote" )
  17.     private double cote;
  18.    
  19. @JsonIgnore
  20.     @Column(name="synopsis", columnDefinition="TEXT", nullable=false)
  21.     private String synopsis;
  22.    
  23.     @Column(name="cover" )
  24.     private String cover;
  25.    
  26.     @JsonIgnore
  27.     @Column(name="trailer" )
  28.     private String trailer;
  29.    
  30.     @JsonIgnore
  31.     @Column(name="duree" )
  32.     private String duree;
  33.    
  34.     @Column(name="alphabetique" )
  35.     private char alphabetique;
  36.    
  37.     @Column(name="url" )
  38.     private String url;
  39.    
  40.     @JsonIgnore
  41.     @Column(name="likes", nullable=false)
  42.     private int like;
  43.    
  44.     @JsonIgnore
  45.     @Column(name="dontlikes", nullable=false)
  46.     private int dontLike;
  47.    
  48.     @JsonIgnore
  49.     @OneToOne
  50.     private Public publicCible;
  51.     @JsonIgnore
  52.     @ManyToMany(fetch=FetchType.LAZY)
  53.     @JoinTable(name="series_nationalites" )
  54.     private Set<Nationalite> nationalites = new HashSet<Nationalite>();
  55.    
  56.     @JsonIgnore
  57.     @ManyToMany(fetch=FetchType.LAZY)
  58.     @JoinTable(name="series_acteurs" )
  59.     private Set<Personne> acteurs = new HashSet<Personne>();
  60.    
  61.     @JsonIgnore
  62.     @ManyToMany(fetch=FetchType.LAZY)
  63.     @JoinTable(name="series_realisateurs" )
  64.     private Set<Personne> realisateurs = new HashSet<Personne>();
  65.    
  66.     @JsonIgnore
  67.     @ManyToMany(fetch=FetchType.LAZY)
  68.     @JoinTable(name="series_themes" )
  69.     private Set<Theme> themes = new HashSet<Theme>();
  70.    
  71.     @JsonIgnore
  72.     @OneToOne
  73.     private Categorie categorie;
  74.  
  75.     @JsonIgnore
  76.     @OneToMany
  77.     private List<Critique> critiques;
  78.    
  79.     /**
  80.  *
  81.  * Constructors
  82.  */
  83.     public Serie() { }
  84.    
  85.     public Serie(long id, String titre, char alphabetique, String cover, String url) {
  86.      this.setTitre(titre);
  87.      this.setAlphabetique(alphabetique);
  88.      this.setCover(cover);
  89.      this.setId(id);
  90.      this.setUrl(url);
  91.     }
  92.    
  93.     public Serie(long id, String titre, char alphabetique, String cover, String url, String synopsis, String duree, int date, Categorie categorie) {
  94.      this.setTitre(titre);
  95.      this.setAlphabetique(alphabetique);
  96.      this.setCover(cover);
  97.      this.setId(id);
  98.      this.setUrl(url);
  99.      this.setSynopsis(synopsis);
  100.      this.setDuree(duree);
  101.      this.setDate(date);
  102.      this.setCategorie(categorie);
  103.     }
  104.        
  105.     /**
  106.  *
  107.  * Getters
  108.  */
  109.     public String getTitre()
  110.     {
  111.         return this.titre;
  112.     }
  113.    
  114.     public String getTitreOriginal()
  115.     {
  116.         return this.titreOriginal;
  117.     }
  118.    
  119.     public int getDate()
  120.     {
  121.         return this.date;
  122.     }
  123.    
  124.     public double getCote()
  125.     {
  126.         return this.cote;
  127.     }
  128.    
  129.     public String getSynopsis()
  130.     {
  131.         return this.synopsis;
  132.     }
  133.    
  134.     public String getCover()
  135.     {
  136.         return this.cover;
  137.     }
  138.    
  139.     public String getTrailer()
  140.     {
  141.         return this.trailer;
  142.     }
  143.    
  144.     public String getDuree()
  145.     {
  146.      return this.duree;
  147.     }
  148.    
  149.     public Set<Nationalite> getNationalites()
  150.     {
  151.      return this.nationalites;
  152.     }
  153.    
  154.     public Public getPublicCible()
  155.     {
  156.      return this.publicCible;
  157.     }
  158.    
  159.     public char getAlphabetique()
  160.     {
  161.      return this.alphabetique;
  162.     }
  163.    
  164.     public String getUrl()
  165.     {
  166.      return this.url;
  167.     }
  168.    
  169.     public int getLike()
  170.     {
  171.      return this.like;
  172.     }
  173.    
  174.     public int getDontLike()
  175.     {
  176.      return this.dontLike;
  177.     }
  178.    
  179.     public Set<Personne> getActeurs()
  180.     {
  181.      return this.acteurs;
  182.     }
  183.    
  184.     public Set<Theme> getThemes()
  185.     {
  186.      return this.themes;
  187.     }
  188.     public Set<Personne> getRealisateurs()
  189.     {
  190.      return this.realisateurs;
  191.     }
  192.      
  193.     public List<Critique> getCritiques()
  194.     {
  195.      return this.critiques;
  196.     }
  197.    
  198.     public Categorie getCategorie()
  199.     {
  200.      return this.categorie;
  201.     }
  202.    
  203.     /**
  204.  *
  205.  * Setters
  206.  */
  207.     public void setTitre(String titre)
  208.     {
  209.         this.titre = titre;
  210.     }
  211.    
  212.     public void setTitreOriginal(String titreOriginal)
  213.     {
  214.         this.titreOriginal = titreOriginal;
  215.     }
  216.    
  217.     public void setDate(int date)
  218.     {
  219.         this.date = date;
  220.     }
  221.    
  222.     public void setCote(double cote)
  223.     {
  224.         this.cote = cote;
  225.     }
  226.    
  227.     public void setSynopsis(String synopsis)
  228.     {
  229.         this.synopsis = synopsis;
  230.     }
  231.    
  232.     public void setCover(String cover)
  233.     {
  234.         this.cover = cover;
  235.     }
  236.    
  237.     public void setDuree(String duree)
  238.     {
  239.      this.duree = duree;
  240.     }
  241.     public void setTrailer(String trailer)
  242.     {
  243.         this.trailer = trailer;
  244.     }
  245.    
  246.     public void setPublicCible(Public publicCible)
  247.     {
  248.      this.publicCible = publicCible;
  249.     }
  250.    
  251.     public void setAlphabetique(char alphabetique)
  252.     {
  253.      this.alphabetique = alphabetique;
  254.     }
  255.    
  256.     public void setUrl(String url)
  257.     {
  258.      this.url = url;
  259.     }
  260.    
  261.     public void setCategorie(Categorie categorie)
  262.     {
  263.      this.categorie = categorie;
  264.     }
  265.    
  266.     /**
  267.  *
  268.  * Methods
  269.  */
  270.     public void addNationalite(Nationalite nationalite)
  271.     {
  272.         this.nationalites.add(nationalite);
  273.     }
  274.    
  275.     public void removeNationalite(Nationalite nationalite)
  276.     {
  277.         this.nationalites.remove(nationalite);
  278.     }
  279.    
  280.     public void addActeur(Personne personne)
  281.     {
  282.         this.acteurs.add(personne);
  283.     }
  284.    
  285.     public void removeActeur(Personne personne)
  286.     {
  287.         this.acteurs.remove(personne);
  288.     }
  289.    
  290.     public void addRealisateur(Personne personne)
  291.     {
  292.      this.realisateurs.add(personne);
  293.     }
  294.    
  295.     public void removeRealisateur(Personne personne)
  296.     {
  297.      this.realisateurs.remove(personne);
  298.     }
  299.    
  300.     public void addTheme(Theme theme)
  301.     {
  302.      this.themes.add(theme);
  303.     }
  304.    
  305.     public void removeTheme(Theme theme)
  306.     {
  307.      this.themes.remove(theme);
  308.     } 
  309.    
  310.     public void addCritique(Critique critique)
  311.     {
  312.      this.critiques.add(critique);
  313.     }
  314.    
  315.     public void removeCritique(Critique critique)
  316.     {
  317.      this.critiques.remove(critique);
  318.     }
  319.    
  320.     public void addLike()
  321.     {
  322.      this.like++;
  323.     }
  324.    
  325.     public void addDontLike()
  326.     {
  327.      this.dontLike++;
  328.     }
  329. }


 
Critique :
 

Code :
  1. @Entity
  2. @Table(name="critiques" )
  3. public class Critique extends BaseEntity
  4. {
  5. @Column(name="titre", nullable=false)
  6. private String titre;
  7. @Column(name="critique", columnDefinition="TEXT", nullable=false)
  8. private String critique;
  9. @Column(name="date", columnDefinition="DATETIME" )
  10. @DateTimeFormat(pattern="dd/MM/yyyy HH:mm:ss" )
  11. private Date date;
  12. @Column(name="likes" )
  13. private int like;
  14. @Column(name="dontlikes" )
  15. private int dontlike;
  16. @Column(name="cotation" )
  17. private int cotation;
  18. @OneToOne
  19.     private User user;
  20. @OneToMany(mappedBy="commentaire" )
  21.     private List<Commentaire> commentaires;
  22. public Critique() {}
  23. public String getTitre() {
  24.  return this.titre;
  25. }
  26. public String getCritique() {
  27.  return this.critique;
  28. }
  29. public Date getDate() {
  30.  return this.date;
  31. }
  32. public int getLike() {
  33.  return this.like;
  34. }
  35. public int getDontLike() {
  36.  return this.dontlike;
  37. }
  38. public int getCotation() {
  39.  return this.cotation;
  40. }
  41. public User getUser() {
  42.  return this.user;
  43. }
  44. public void setTitre(String titre) {
  45.  this.titre = titre;
  46. }
  47. public void setCritique(String critique) {
  48.  this.critique = critique;
  49. }
  50. public void setUser(User user) {
  51.  this.user = user;
  52. }
  53. public void setDate(Date date) {
  54.  this.date = date;
  55. }
  56. public void setCotation(int cotation) {
  57.  this.cotation = cotation;
  58. }
  59. public void addLike() {
  60.  this.like++;
  61. }
  62. public void addDontLike() {
  63.  this.dontlike++;
  64. }
  65. public List<Commentaire> getCommentaires()
  66.     {
  67.      return this.commentaires;
  68.     }
  69.  public void addCommentaire(Commentaire commentaire)
  70.     {
  71.         this.commentaires.add(commentaire);
  72.     }
  73.    
  74.     public void removeCommentaire(Commentaire commentaire)
  75.     {
  76.         this.commentaires.remove(commentaire);
  77.     }
  78. }


 
 
Si vous saviez me dire comment bien modéliser cela, ça m'aiderais énormément.
 
Si vous voyez d'autres erreurs ou incohérence dans mon code, n'hésitez pas.
 
Merci d'avance

Message cité 1 fois
Message édité par deli2025 le 21-03-2017 à 14:45:10
mood
Publicité
Posté le 21-03-2017 à 14:42:55  profilanswer
 

n°2298072
deli2025
Posté le 21-03-2017 à 19:06:18  profilanswer
 

Bon, j'ai résolu le problème 1 en créant une bidirectionnalité me permettant ceci :
 

Code :
  1. SELECT ct FROM CategorieTheme ct JOIN ct.categorie c WHERE c.url = :url AND ct.id <> 5


 
 
Maintenant, je n'explique toujours pas le fait que je n'arrive pas à mettre une contrainte sur un objet enfant et pouvoir procéder comme ceci :
 

Code :
  1. SELECT DISTINCT c.categoriesThemes FROM Categorie c JOIN c.categoriesThemes ct WHERE c.url = :url AND ct.id <> 5


 
 
Si vous avez une explication...
 
Personne pour le problème 2 ?

n°2298086
Soileh
Lurkeur professionnel
Posté le 22-03-2017 à 07:24:57  profilanswer
 

deli2025 a écrit :

Bonjour,  
 
Je viens vers vous pour résoudre 2 problèmes que je rencontre actuellement.
 
Problème 1 :
 
J'essaie de récupérer toutes les categoriesThemes (Lieux, Périodes, Civilisations, Genres,...) d'une categorie (Films, Téléfilms, Documentaires,...) en rejetant une categoriesThemes précise par son ID.
 
Voici ma requête : SELECT DISTINCT c.categoriesThemes FROM Categorie c JOIN c.categoriesThemes ct WHERE c.id = :id AND ct.id <> 5
 
Mais cela ne fonction pas, je retrouve bien dans mes résultats la categoriesThemes possédant l'id N° 5...
 
[...]
 
Si vous saviez me dire comment bien modéliser cela, ça m'aiderais énormément.
 
Si vous voyez d'autres erreurs ou incohérence dans mon code, n'hésitez pas.
 
Merci d'avance


 :hello: !
Vu comme ça, il me semble qu'il te manque une partie dans ta requête : la condition de jointure  :??:  

Code :
  1. SELECT DISTINCT c.categoriesThemes FROM Categorie c JOIN c.categoriesThemes ct ON ct.id = c.id WHERE c.id = :id AND ct.id <> 5


Par contre, ça me parait étrange quand même : categoriesThemes et Categorie doivent être des tables. On dirait que ce n'est pas le cas :??:  
 :jap:


Message édité par Soileh le 22-03-2017 à 07:27:08

---------------
And in the end, the love you take is equal to the love you make

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Java

  Problème de relation JAVA EE

 

Sujets relatifs
Alignement d'articles.. Problème HTML/CSS[JAVA] javax.awt manquant
Problème de mise en relation formulaire\BaseDeDonnée + Erreur.je trouve pas le probleme dans le code
Problème script javascriptxpadder probleme
probléme avec plugin que je voudrai absolument utiliséProbleme AJAX et JEE/servlet
[Java] Arrêt traitement si doublons dans champ d'un fichier 
Plus de sujets relatifs à : Problème de relation JAVA EE


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR