Bonjour,
J'utilise comme Spring 2.0.6et comme hiebernate 3.2.6.ga.
Je voudrais utiliser les annotations pour configurer l'accés au donné via Hibernate.
Pourcela j'ai utilisé un fichier Application-hibernate-context.xml
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
 
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
    <bean id="dataSource"
          class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName">
            <value>org.postgresql.Driver</value>
        </property>
        <property name="url">
            <value>jdbc:postgresql://localhost:5432/kmji18n</value>
        </property>
        <property name="username">
            <value>postgres</value>
        </property>
        <property name="password">
            <value>postgres</value>
        </property>
    </bean>
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource">
            <ref bean="dataSource"/>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
            </props>
        </property>
        <property name="annotatedClasses">
            <list>                           <value>kmji18n.implementation.element.Label</value>
            </list>
        </property>
    </bean>
    <!--Hibernate-->
    <bean id="hibernateTemplate"
          class="org.springframework.orm.hibernate3.HibernateTemplate">
        <constructor-arg ref="sessionFactory"/>
    </bean>
</beans>
et dans mon classe Lavel:
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
 
@Entity
@Table(name = "I18_LABEL")
 
@NamedQueries(
        {
        @NamedQuery(
                name = "label.findByLocale",
                query = "from Label label where upper(label.labelPK.locale)=upper(?)"
        ),
        @NamedQuery(
                name = "label.findAllCriteria",
                query = "  from Label label where upper(label.labelPK.locale)=upper(?) and upper(label.labelPK.key)=upper(?) and\n" +
                        "        upper(label.value)=upper(?)"
        ),
        @NamedQuery(
                name = "label.findAllKeys",
                query = "select label.labelPK.key from Label label"
        )
                ,
        @NamedQuery(
                name = "label.findKeysByLocale",
                query = "   delete from Label label where upper(label.labelPK.locale)=upper(?)"
        )
                ,
        @NamedQuery(
                name = "label.deleteByLocale",
                query = "delete from Label label where upper(label.labelPK.locale)=upper(?)"
        )
                ,
        @NamedQuery(
                name = "label.deleteByKey",
                query = "delete from Label label where upper(label.labelPK.key) like upper(?)"
        )
                ,
        @NamedQuery(
                name = "label.deleteAll",
                query = "delete from Label label"
        )
                }
)
public class Label implements ILabel {
    @Id
    private LabelPK labelPK = new LabelPK();
    @SuppressWarnings("unused")
    @Column(name = "I18_KEY", nullable = false, updatable = false, insertable = false)
    private String key;
    @SuppressWarnings("unused")
    @Column(name = "I18_LOCALE", nullable = false, updatable = false, insertable = false)
    private String locale;
    @Column(name = "I18_VALUE")
    private String value;
 
    public String getKey() {
        return labelPK.getKey();
    }
 
 
    public void setKey(String _key) {
        this.labelPK.setKey(_key);
        this.key = _key;
    }
 
    public String getLocale() {
        return this.labelPK.getLocale();
    }
 
    public void setLocale(String _locale) {
        this.labelPK.setLocale(_locale);
 
        this.locale = _locale;
    }
 
    public Label() {
        super();
    }
 
   public Label(LabelPK _labelPK, String _value) {
        this();
        this.labelPK = _labelPK;
        this.key = _labelPK.getKey();
        this.locale = _labelPK.getLocale();
        this.value = _value;
    }
 
    public void setPrimaryKey(LabelPK _labelPK) {
        this.labelPK = _labelPK;
    }
 
   public LabelPK getPrimaryKey() {
        return this.labelPK;
    }
 
    public LabelPK getLabelPK() {
        return this.labelPK;
    }
 
    public void setLabelPK(LabelPK _labelPK) {
        this.labelPK = _labelPK;
    }
 
    public String getValue() {
        return value;
    }
 
 
    public void setValue(String _value) {
        this.value = _value;
    }
 
 
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
 
        Label label = (Label) o;
 
        if (!this.getPrimaryKey().equals(label.getPrimaryKey())) {
            return false;
        }
        if (!value.equals(label.value)) {
            return false;
        }
        return true;
    }
 
    public int hashCode() {
        int result;
        result = this.getPrimaryKey().hashCode();
        result = 31 * result + value.hashCode();
        return result;
    }
 
 
}
Mais ça parait que la classe n'est pas persisté il me signale null pointer exception lorsque j'ai voulu créer un nouveau élément.

y'a t' il quelqu'un qui a rencontré ce genre de problème .

beaucoup d'avance