Bonjour.

J'ai une entité EntityBudyPhone qui définit une table d'association many-to-many entre Phone et Budy.
(une personne peut avoir plusieurs téléphones, mais on peut aussi joindre plusieurs personnes en appelant un seul numéro)

Voici ma classe :

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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package org.gfarny.ejb3;
 
import java.io.Serializable;
 
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.ejb.CreateException;
 
@Entity
@Table(name="phone_rel_bud", uniqueConstraints = @UniqueConstraint(columnNames = {"phone_fk","budy_fk"}))
public class EntityBudyPhone implements Serializable {
 
	private static final long serialVersionUID = 4037447988458724371L;
 
	@Embeddable
	public static class Id implements Serializable {
		private static final long serialVersionUID = -9040939392333356524L;
 
		@Column(name="budy_fk", nullable=false)
		private int budyFk = 0;
 
		@Column(name="phone_fk", nullable=false)
		private int phoneFk = 0;
 
		public void setBudyFk(int b) {
			this.budyFk = b;
		}
 
		public int getBudyFk() {
			return budyFk;
		}
 
		public void setPhoneFk(int p) {
			this.phoneFk = p;
		}
 
		public int getPhoneFk() {
			return phoneFk;
		}
 
		Id() {}
 
		Id(int budyFk, int phoneFk) {
			setBudyFk(budyFk);
			setPhoneFk(phoneFk);
		}
 
		public String toString() {
			return String.format("EntityBudyPhone[%d,%d]", getBudyFk(), getPhoneFk());
		}
 
		public int hashCode() {
			return this.toString().hashCode();
		}
 
		public boolean equals(Id i) {
			if (this.budyFk == i.getBudyFk())
				if (this.phoneFk == i.getPhoneFk())
					return true;
			return false;
		}
	}
 
	@EmbeddedId
	private Id id;
 
	// JPA ne doit pas gérer cette clé étrangère (insertable = false, updatable = false)
	@ManyToOne
	@JoinColumn(name="budy_fk", insertable=false, updatable=false, nullable=false)
	private EntityBudy entityBudy;
 
	// JPA ne doit pas gérer cette clé étrangère (insertable = false, updatable = false)
	@ManyToOne
	@JoinColumn(name="phone_fk", insertable=false, updatable=false, nullable=false)
	private EntityPhone entityPhone;
 
	public Id getId() {
		return id;
	}
 
	public void setEntityBudy(EntityBudy eb) {
		entityBudy = eb;
	}
 
	public EntityBudy getEntityBudy() {
		return entityBudy;
	}
 
	public void setEntityPhone(EntityPhone ep) {
		entityPhone = ep;
	}
 
	public EntityPhone getEntityPhone() {
		return entityPhone;
	}
 
	public EntityBudyPhone() {}
 
	public EntityBudyPhone(EntityBudy eb, EntityPhone ep) {
		id = new Id(eb.getId(), ep.getId());
		setEntityBudy(eb);
		setEntityPhone(ep);
		eb.getEntityBudyPhoneSet().add(this);
		ep.getEntityBudyPhoneSet().add(this);
	}
 
	public boolean equals (EntityBudyPhone ebp) {
		if (this.id.equals(ebp.getId()))
				return true;
		return false;
	}
}
Lorsque je déploie, Hibernate prétend que :

Code console : Sélectionner tout - Visualiser dans une fenêtre à part
12:21:14,642 WARN  [org.hibernate.mapping.RootClass] (ServerService Thread Pool -- 79) HHH000038: Composite-id class does not override equals(): org.gfarny.ejb3.EntityBudyPhone$Id

Ma méthode equals() est bien présente. "Override", voilà le problème. Quelle superclasse ma classe imbriquée Id{} devrait-elle surcharger / étendre ?


Merci.