lolilady

Esercizio hibernate(Classe Chat)

Sep 10th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.58 KB | None | 0 0
  1. package it.unibas.forum.modello;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import javax.persistence.*;
  6.  
  7.  
  8. @Entity
  9.  
  10. public class Chat {
  11.     private long id;
  12.     private String nome;
  13.     private String argomento;
  14.     private List<Utente> listaUtenti = new ArrayList<Utente>();
  15.     private List<Messaggio> listaMessaggi = new ArrayList<Messaggio>();
  16.  
  17.     public Chat() {
  18.     }
  19.    
  20.    
  21.  
  22.     public Chat(String nome, String argomento) {
  23.         this.nome = nome;
  24.         this.argomento = argomento;
  25.     }
  26.  
  27.     @Id
  28.     @GeneratedValue(strategy = GenerationType.TABLE)
  29.     public long getId() {
  30.         return id;
  31.     }
  32.  
  33.     public void setId(long id) {
  34.         this.id = id;
  35.     }
  36.  
  37.     @Column(unique = true)
  38.     public String getNome() {
  39.         return nome;
  40.     }
  41.  
  42.     public void setNome(String nome) {
  43.         this.nome = nome;
  44.     }
  45.  
  46.     public String getArgomento() {
  47.         return argomento;
  48.     }
  49.  
  50.     public void setArgomento(String argomento) {
  51.         this.argomento = argomento;
  52.     }
  53.  
  54.     @OneToMany(mappedBy = "chat",cascade = CascadeType.ALL)
  55.     public List<Utente> getListaUtenti() {
  56.         return listaUtenti;
  57.     }
  58.  
  59.     public void setListaUtenti(List<Utente> listaUtenti) {
  60.         this.listaUtenti = listaUtenti;
  61.     }
  62.  
  63.     @OneToMany(mappedBy = "chat",orphanRemoval = true,cascade = CascadeType.ALL)
  64.     public List<Messaggio> getListaMessaggi() {
  65.         return listaMessaggi;
  66.     }
  67.  
  68.     public void setListaMessaggi(List<Messaggio> listaMessaggi) {
  69.         this.listaMessaggi = listaMessaggi;
  70.     }
  71.    
  72.    
  73.    
  74. }
Add Comment
Please, Sign In to add comment