1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
@Entity
@Table(name = "AUTEUR")
@NamedQueries({@NamedQuery(name = "Auteur.findAll", query = "SELECT a FROM Auteur a"), @NamedQuery(name = "Auteur.findById", query = "SELECT a FROM Auteur a WHERE a.id = :id"), @NamedQuery(name = "Auteur.findByNom", query = "SELECT a FROM Auteur a WHERE a.nom = :nom"), @NamedQuery(name = "Auteur.findByPrenom", query = "SELECT a FROM Auteur a WHERE a.prenom = :prenom"), @NamedQuery(name = "Auteur.findByNationalite", query = "SELECT a FROM Auteur a WHERE a.nationalite = :nationalite"), @NamedQuery(name = "Auteur.findByPresentation", query = "SELECT a FROM Auteur a WHERE a.presentation = :presentation")})
public class Auteur implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "id")
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
@Basic(optional = false)
@Column(name = "nom", nullable = false)
private String nom;
@Basic(optional = false)
@Column(name = "prenom", nullable = false)
private String prenom;
@Basic(optional = false)
@Column(name = "nationalite", nullable = false)
private String nationalite;
@Basic(optional = false)
@Column(name = "presentation", nullable = false)
private String presentation;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "idAuteur", fetch = FetchType.EAGER)
@OrderBy("titre ASC")
private List<Ouvrage> ouvrageList;
@PrePersist
@PreUpdate
private void validerDonnees()
{
if ( nom == null || "".equals(nom) )
throw new ValidationException("Nom invalide");
if ( prenom == null || "".equals(prenom) )
throw new ValidationException("Prenom invalide");
if( nationalite == null || "".equals(nationalite) )
throw new ValidationException("Nationalité invalide");
if( presentation == null || "".equals(presentation) )
throw new ValidationException("Presentation invalide");
}
public Auteur() {
}
public Auteur(Long id) {
this.id = id;
}
(+ constructeurs, getters, setters, equals() et toString() )
} |
Partager