Bonsoir à tous,
S'il vous plait, j'ai besoin d'aide. J'essaie de créer, avec JPA, une relation bidirectionnelle OneToMany, mais j'ai les erreurs suivantes:
"[EclipseLink-63] : The instance creation method [entity.OrderLine.], with no parameters, does not exist, or is not accessible. [EclipseLink-28019] : Deployment of PersistenceUnit [simple-jpaPU] failed. Close all factories for this PersistenceUnit."
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81 package entity; import java.util.*; import java.io.Serializable; import javax.persistence.*; import org.eclipse.persistence.annotations.TimeOfDay; /** * * @author berra */ @Entity public class Order implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @Temporal(TemporalType.TIMESTAMP) private Date creationDate; @OneToMany(mappedBy = "o") private List<OrderLine> orderLines; public Date getCreationDate() { return creationDate; } public void setCreationDate(Date creationDate) { this.creationDate = creationDate; } public List<OrderLine> getOrderLines() { return orderLines; } public void setOrderLines(ArrayList<OrderLine> orderLines) { this.orderLines = orderLines; } public Order(Date creationDate) { this.creationDate = creationDate; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } @Override public int hashCode() { int hash = 0; hash += (id != null ? id.hashCode() : 0); return hash; } @Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Order)) { return false; } Order other = (Order) object; if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { return false; } return true; } @Override public String toString() { return "entity.Order[ id=" + id + " ]"; } }S'il vous plait, est-ce que quelqu'un peut m'aider ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92 package entity; import java.io.Serializable; import javax.persistence.*; /** * * @author berra */ @Entity @Table(name="orderline_table") public class OrderLine implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String item; private Double unitPrice; private Integer quantity; @ManyToOne Order o; public String getItem() { return item; } public void setItem(String item) { this.item = item; } public Double getUnitPrice() { return unitPrice; } public void setUnitPrice(Double unitPrice) { this.unitPrice = unitPrice; } public Integer getQuantity() { return quantity; } public void setQuantity(Integer quantity) { this.quantity = quantity; } public OrderLine(String item, Double unitPrice, Integer quantity) { this.item = item; this.unitPrice = unitPrice; this.quantity = quantity; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } @Override public int hashCode() { int hash = 0; hash += (id != null ? id.hashCode() : 0); return hash; } @Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof OrderLine)) { return false; } OrderLine other = (OrderLine) object; if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { return false; } return true; } @Override public String toString() { return "entity.OrderLine[ id=" + id + " ]"; } }
Partager