Bonjour,

Je n'arrive pas trouver l'équivalence en annotation de ce fichier xml avec l'utilisation d'une EventList de la librairie GlazedList.
J'ai lu qu'il faut utiliser collection-type="ca.odell.glazedlists.hibernate.EventListType" mais j'ai toujours l'erreur suivante:
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
javax.persistence.PersistenceException: [PersistenceUnit: BasketBallTrainerPU] Unable to configure EntityManagerFactory
	at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:265)
	at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:125)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:110)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
	at gmo.basketballtrainer.utils.HibernateUtil.<clinit>(HibernateUtil.java:19)
Caused by: org.hibernate.AnnotationException: Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements: gmo.basketballtrainer.model.Evolution.drawableList
	at org.hibernate.cfg.annotations.CollectionBinder.getCollectionBinder(CollectionBinder.java:264)
	at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1455)
	at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:754)
	at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:534)
	at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:286)
	at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
	at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1225)
	at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:159)
	at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:854)
	at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:191)
	at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:253)
	... 4 more
 
 
 The following providers:
oracle.toplink.essentials.PersistenceProvider
oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider
Returned null to createEntityManagerFactory.
 
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:154)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
	at gmo.basketballtrainer.utils.HibernateUtil.<clinit>(HibernateUtil.java:19)
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 2 seconds)
Mon fichier xml qui fonctionne:
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
<hibernate-mapping>
    <class name="gmo.basketballtrainer.model.Evolution" table="Evolution">
        <id name="id" type="int" column="id">
            <generator class="increment"/>
        </id>
        <property name="name" column="name"/>
        <property name="evolutionTime" column="evolutionTime"/>
        <property name="principe" column="principe"/>
        <property name="requirement" column="requirement"/>
        <property name="evolutionImage" column="evolutionImage"/>
        <list name="drawableList" cascade="all" collection-type="ca.odell.glazedlists.hibernate.EventListType">
            <key column="evolution_id"/>
            <list-index column="idx"/>
            <one-to-many class="gmo.basketballtrainer.model.drawableabstract.Drawable"/>
        </list>
    </class>
</hibernate-mapping>
L'équivalence en annotation:

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
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gmo.basketballtrainer.model;
 
import ca.odell.glazedlists.BasicEventList;
import ca.odell.glazedlists.EventList;
import gmo.basketballtrainer.model.drawableabstract.Drawable;
import java.io.Serializable;
import javax.persistence.*;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.Type;
 
/**
 *
 * @author Spiritkill
 */
@Entity
public class Evolution implements Serializable {
 
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Integer id;
    private String name;
    private int evolutionTime;
    private String principe;
    private String requirement;
    @OneToMany(mappedBy = "evolution",cascade= CascadeType.ALL)
    @Type(type="ca.odell.glazedlists.hibernate.EventListType")
    @Index(name="idx")
    private EventList<Drawable> drawableList;
    private String evolutionImage;
    @ManyToOne
    private Exercise exercise;
 
    public Evolution() {
        this.name = "Evolution";
        this.evolutionTime = 0;
        this.principe = "";
        this.requirement = "";
        this.drawableList = new BasicEventList<>();
    }
 
    public Evolution(Exercise exercise, String name, int evolutionTime, String principe, String requirement, EventList<Drawable> drawableList) {
        this.name = name;
        this.evolutionTime = evolutionTime;
        this.principe = principe;
        this.requirement = requirement;
        this.drawableList = drawableList;
    }
 
    public EventList<Drawable> getDrawableList() {
        return drawableList;
    }
 
    public void setDrawableList(EventList<Drawable> drawableList) {
        this.drawableList = drawableList;
    }
 
    public int getEvolutionTime() {
        return evolutionTime;
    }
 
    public void setEvolutionTime(int evolutionTime) {
        this.evolutionTime = evolutionTime;
    }
 
    public String getName() {
        return name;
    }
 
    public void setName(String name) {
        this.name = name;
    }
 
    public String getEvolutionImage() {
        return evolutionImage;
    }
 
    public void setEvolutionImage(String evolutionImage) {
        this.evolutionImage = evolutionImage;
    }
 
    public String getPrincipe() {
        return principe;
    }
 
    public void setPrincipe(String principe) {
        this.principe = principe;
    }
 
    public String getRequirement() {
        return requirement;
    }
 
    public void setRequirement(String requirement) {
        this.requirement = requirement;
    }
 
    public Integer getId() {
        return id;
    }
 
    public void setId(Integer id) {
        this.id = id;
    }
 
    @Override
    public String toString() {
        return name;
    }
}
Merci.