Bonjour,

J'ai deux entités qui sont ArtifactCard et CompositeCard que voici

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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
package ch.culturalnetwork.core.model;
 
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
 
/**
 *
 * @author avillar
 */
@Entity
@XmlRootElement
public class ArtifactCard implements Serializable {
 
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "artifactCard_id")
    private Long id;
    @Column(name = "artifactCard_file", nullable = false)
    private String file;
    @Column(name = "artifactCard_typefile", nullable = false)
    private String typefile;
    @Column(name = "artifactCard_author", nullable = false)
    private String author;
    @Column(name = "artifactCard_title_topic", nullable = false)
    private String title_topic;
    @Column(name = "artifactCard_year", nullable = false)
    private String year;
    @Column(name = "artifactCard_technical", nullable = false)
    private String technical;
    @Column(name = "artifactCard_support_media", nullable = false)
    private String support_media;
    // the format can be in cm or in duration
    @Column(name = "artifactCard_format", nullable = false)
    private String format;
    @Column(name = "artifactCard_owner", nullable = false)
    private String owner;
    @Column(name = "artifactCard_collocation")
    private String collocation;
    @Column(name = "artifactCard_description_remarks")
    private String descritpion_remarks;
//    @JoinColumn(name = "compositeCard_ID", referencedColumnName = "compositeCard_id")
//    @ManyToOne(cascade = CascadeType.ALL)
//    private CompositeCard compositeCard;
    @ManyToMany(cascade= CascadeType.ALL)
     @JoinTable(name="ARTCARD_COMPCARD  ",
                 joinColumns=
                      @JoinColumn(name="artifactCard_id"),
                 inverseJoinColumns=
                      @JoinColumn(name="compositeCard_id")
     )
     private Collection<CompositeCard> compositeCard;
 
    public ArtifactCard() {
    }
 
    public ArtifactCard(String file, String author, String title_topic, String year, String technical, String support_media, String format, String owner, String collocation, String description_remarks) {
        this.file = file;
        this.author = author;
        this.title_topic = title_topic;
        this.year = year;
        this.technical = technical;
        this.support_media = support_media;
        this.format = format;
        this.owner = owner;
        this.collocation = collocation;
        this.descritpion_remarks = description_remarks;
 
    }
 
    public Long getId() {
        return id;
    }
 
    public void setId(Long id) {
        this.id = id;
    }
 
    public String getFile() {
        return file;
    }
 
    public void setFile(String file) {
        this.file = file;
    }
 
    public String getTypefile() {
        return typefile;
    }
 
    public void setTypefile(String typefile) {
        this.typefile = typefile;
    }
 
    public String getAuthor() {
        return author;
    }
 
    public void setAuthor(String author) {
        this.author = author;
    }
 
    public String getCollocation() {
        return collocation;
    }
 
    public void setCollocation(String collocation) {
        this.collocation = collocation;
    }
 
    public String getDescritpion_remarks() {
        return descritpion_remarks;
    }
 
    public void setDescritpion_remarks(String descritpion_remarks) {
        this.descritpion_remarks = descritpion_remarks;
    }
 
    public String getFormat() {
        return format;
    }
 
    public void setFormat(String format) {
        this.format = format;
    }
 
    public String getOwner() {
        return owner;
    }
 
    public void setOwner(String owner) {
        this.owner = owner;
    }
 
    public String getSupport_media() {
        return support_media;
    }
 
    public void setSupport_media(String support_media) {
        this.support_media = support_media;
    }
 
    public String getTechnical() {
        return technical;
    }
 
    public void setTechnical(String technical) {
        this.technical = technical;
    }
 
    public String getTitle_topic() {
        return title_topic;
    }
 
    public void setTitle_topic(String title_topic) {
        this.title_topic = title_topic;
    }
 
    public String getYear() {
        return year;
    }
 
    public void setYear(String year) {
        this.year = year;
    }
 
    public Collection<CompositeCard> getCompositeCard() {
        return compositeCard;
    }
 
    public void setCompositeCard(Collection<CompositeCard> compositeCard) {
        this.compositeCard = compositeCard;
    }
 
 
 
    @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 ArtifactCard)) {
            return false;
        }
        ArtifactCard other = (ArtifactCard) 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 "ch.culturalnetwork.core.model.CardArtifact[ id=" + id + " ]";
    }
}
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
package ch.culturalnetwork.core.model;
 
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
 
/**
 *
 * @author avillar
 */
@Entity
@XmlRootElement
public class CompositeCard implements Serializable {
 
    private static final long serialVersionUID = 1L;
        private Long id;
        private String name;
        private CulturalArtifact culturalArtifact;
//    @OneToMany(cascade = CascadeType.ALL, mappedBy = "compositeCard")
//    private List<ArtifactCard> artifactCardList;
    private Collection<ArtifactCard> artifactCards;
 
 
    public CompositeCard() {
    }
 
    public CompositeCard(String name) {
        this.name = name;
    }
    //</editor-fold>
 
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "compositeCard_id")
    public Long getId() {
        return id;
    }
 
    public void setId(Long id) {
        this.id = id;
    }
 
    @Column(name = "compositeCard_name", nullable = false)
    public String getName() {
        return name;
    }
 
    public void setName(String name) {
        this.name = name;
    }
 
 
 
    @OneToOne(mappedBy = "compositeCard")
    public CulturalArtifact getCulturalArtifact() {
        return culturalArtifact;
    }
 
    public void setCulturalArtifact(CulturalArtifact culturalArtifact) {
        this.culturalArtifact = culturalArtifact;
    }
     @ManyToMany(mappedBy="compositeCard")
    public Collection<ArtifactCard> getArtifactCards() {
        return artifactCards;
    }
 
    public void setArtifactCards(Collection<ArtifactCard> artifactCards) {
        this.artifactCards = artifactCards;
    }
 
    @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 CompositeCard)) {
            return false;
        }
        CompositeCard other = (CompositeCard) 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 "ch.culturalnetwork.core.model.CompositeCard[ id=" + id + " ]";
    }
}
Donc comme vous pouvez le voir j'ai une relation many-to-many.

Ensuite en PHP, je crée des ArtifactCard et lorsque que je crée une CompositeCard je sélectionne des ArtifactCard et souhaitais que les liens se fassent tous seuls, mais non. Il parait que c'est un problème soit de Framework Java ou de mes services REST.

Autant mes services REST que la BD (derby) ont été créés automatiquement depuis mes entités.

Quelqu'un saurait-il m'indiquer comment faire ?

Merci d'avance pour votre aide.