The five entity bean :
Customer :
Code:
@Entity
@Name("Customer")
public class Customer implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long customerId;
private String companyName;
private String form;
private String tva;
private String emailInvoices;
@Column(nullable = false)
private String adress1;
private String adress2;
@Column(nullable = false)
private Long postalCode;
@Column(nullable = false)
private String city;
@Column(nullable = false)
private String country;
private Long phone;
@Column(nullable = false)
private Long fax;
/**
*Creates the foreign key in relation to the Order table
*/
@OneToMany(mappedBy = "customer", cascade = CascadeType.PERSIST)
private List<Order> orders;
/**
*Creates the foreign key in relation to the Contact table
*/
@OneToMany(mappedBy = "customer", cascade = CascadeType.PERSIST)
private List<Contact> contacts;
/** Creates a new instance of Client */
public Customer() {
}
getters and setters......
Order
Code:
@Entity
@Table(name = "client_order")
public class Order implements Serializable {
public static enum PaymentType {creditcard, transfert, check};
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long orderId;
@Column(nullable = false)
@Temporal(TemporalType.DATE)
private Date orderDate;
@Column(nullable = false)
@Temporal(TemporalType.DATE)
private Date endDate;
@Temporal(TemporalType.DATE)
private Date paymentDate;
private Boolean paymentStatus;
private PaymentType type;
/**
*Creates the foreign key in relation to the Partner table
*/
@ManyToOne
@JoinColumn (name = "partnerId_fk")
private Partner partner;
/**
*Creates the foreign key in relation to the Customer table
*/
@ManyToOne
@JoinColumn (name = "customerId_fk")
private Customer customer;
/**
*This table creates the joint between the purchase order and its lines of order.
*The primary key of this table is consisted of the two foreign keys.
*/
@OneToMany(mappedBy = "order", cascade = CascadeType.PERSIST)
private List<OrderLine> orderLines;
/**
* Creates a new instance of Order
*/
public Order() {
}
.....
OrderLine
Code:
@Entity
@Name("OrderLine")
public class OrderLine implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long lineId;
/**
*Creates the foreign key in relation to the Product table
*/
@OneToOne
@JoinColumn (name = "productId_fk", nullable = false)
private Product product;
/**
*Creates the foreign key in relation to the Contact table
*/
@ManyToOne
@JoinColumn (name = "orderId")
private Order order;
@OneToMany(mappedBy = "line",fetch=FetchType.LAZY, cascade = CascadeType.PERSIST)
private List<Server> servers;
/**
*Creates the foreign key in relation to the Discount table
*/
@ManyToOne
@JoinColumn (name = "discount")
private Discount discount;
/** Creates a new instance of OrderLine */
public OrderLine() {
}
....
Contact
Code:
@Entity
@Name("Contact")
public class Contact implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long contactId;
@Column(nullable = false)
private String firstName;
@Column(nullable = false)
private String lastName;
private Long phone;
private Long otherPhone;
private Long fax;
@Column(nullable = false)
private String mail;
@Column(nullable = false)
private String username;
@Column(nullable = false)
private String password;
private Date notifyStart;
private Date notifyEnd;
private String position;
/**
*Creates the foreign key in relation to the Customer table
*/
@ManyToOne
@JoinColumn (name = "customerId_fk")
private Customer customer;
/**
*Creates the foreign key in relation to the ContactReportBinder table
*/
@OneToMany(mappedBy = "contact", cascade = CascadeType.PERSIST)
private List<ContactReportBinder> Binders;
/** Creates a new instance of Contact */
public Contact() {
}
......
ReportBinder
Code:
@Entity
@Name("ContactReportBinder")
public class ContactReportBinder implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long binderId;
/**
*Creates the foreign key in relation to the Report table
*/
@OneToMany(mappedBy = "binder")
private List<Report> reports;
/**
*Creates the foreign key in relation to the Contact table
*/
@ManyToOne
@JoinColumn (name = "contactId_fk")
private Contact contact;
/**
*Creates the foreign key in relation to the OrderLine table
*/
@OneToOne(cascade=CascadeType.PERSIST)
@JoinColumn(name = "lineId_fk")
private OrderLine line;
/** Creates a new instance of ContactReportBinder */
public ContactReportBinder() {
}
......