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 51 52 53
| /**
* Entity implementation class for Entity: Abonnement
*
*/
@Entity
@Table(name="Abonnement")
public class Abonnement implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue( strategy = GenerationType.IDENTITY)
@Column(name="IdAbonnement")
private int idAbonnement;
@OneToMany(mappedBy="abonnement", fetch=FetchType.EAGER)
private Set<User> user;
}
/**
* Entity implementation class for Entity: User
*
*/
@Entity
@Table(name="User")
public class User implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue( strategy = GenerationType.IDENTITY)
@Column(name="IdUser")
private int idUser;
@Column(name="NomUser")
private String nomUser;
@ManyToOne
@JoinColumn(name="IdAbonnement")
private Abonnement abonnement;
}
public User user_by_idUser (int idUser) throws DAOException {
User user = null;
try {
user = em.find(User.class, idUser);
return user;
} catch ( DAOException e ) {
throw new DAOException( e );
}
} |