Bonjour à tous,
Voici le mapping d'un appel a une procédure stockée.
Lorsque je l'utilise ainsi j'arrive à la faire fonctionné parfaitement.
Maintenant, je voudrais externalisé les paramétres d'appel.
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 <hibernate-mapping> <class name="model.SRfpDistriAR" catalog="CWT_DIR_DEV"> <id name="htlNumber" column="HTLNUMBER" type="integer"> <generator class="native"/> </id> <property name="grpName" column="GRPNAME"/> <property name="grpNumber" column="GRPNUMBER" /> <property name="chnCode" column="CHNCODE"/> <property name="chnNumber" column="CHNNUMBER"/> <property name="htlName" column="HTLNAME"/> <property name="ratNumber" column="RATNUMBER"/> <property name="staCode" column="STACODE"/> <property name="ctcEmail" column="CTCEMAIL"/> <property name="ctcFax" column="CTCFAX"/> <property name="preName" column="PRENAME"/> <property name="namName" column="NAMNAME"/> <property name="cntName" column="CNTNAME"/> <property name="worName" column="WORNAME"/> </class> <sql-query name="S_RFPDISTRIAR" callable="true"> <return alias="toto" class="model.SRfpDistriAR"> <return-property name="grpName" column="GRPNAME"/> <return-property name="grpNumber" column="GRPNUMBER" /> <return-property name="chnCode" column="CHNCODE"/> <return-property name="chnNumber" column="CHNNUMBER"/> <return-property name="htlNumber" column="HTLNUMBER"/> <return-property name="htlName" column="HTLNAME"/> <return-property name="ratNumber" column="RATNUMBER"/> <return-property name="staCode" column="STACODE"/> <return-property name="ctcEmail" column="CTCEMAIL"/> <return-property name="ctcFax" column="CTCFAX"/> <return-property name="preName" column="PRENAME"/> <return-property name="namName" column="NAMNAME"/> <return-property name="cntName" column="CNTNAME"/> <return-property name="worName" column="WORNAME"/> </return> { ? = call S_RFPDISTRIAR ('IBM', 2008, 'A', NULL,0)} </sql-query> </hibernate-mapping>
J'ai donc modifié mon mapping de sorte à obtenir ceci :
Malheureusement, avec cette méthode je n'arrive pas à la faire fonctionné. Quelqu'un aurait il une idée sur ce qui cloche.
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 <hibernate-mapping> <class name="model.SRfpDistriAR" catalog="CWT_DIR_DEV"> <id name="htlNumber" column="HTLNUMBER" type="integer"> <generator class="native"/> </id> <property name="grpName" column="GRPNAME"/> <property name="grpNumber" column="GRPNUMBER" /> <property name="chnCode" column="CHNCODE"/> <property name="chnNumber" column="CHNNUMBER"/> <property name="htlName" column="HTLNAME"/> <property name="ratNumber" column="RATNUMBER"/> <property name="staCode" column="STACODE"/> <property name="ctcEmail" column="CTCEMAIL"/> <property name="ctcFax" column="CTCFAX"/> <property name="preName" column="PRENAME"/> <property name="namName" column="NAMNAME"/> <property name="cntName" column="CNTNAME"/> <property name="worName" column="WORNAME"/> </class> <sql-query name="S_RFPDISTRIAR" callable="true"> <query-param name="clientCode" type="java.lang.String" /> <query-param name="year" type="Integer"/> <query-param name="status" type="String"/> <query-param name="cntCode" type="String"/> <query-param name="removeCCMSent" type="String"/> <return alias="toto" class="model.SRfpDistriAR"> <return-property name="grpName" column="GRPNAME"/> <return-property name="grpNumber" column="GRPNUMBER" /> <return-property name="chnCode" column="CHNCODE"/> <return-property name="chnNumber" column="CHNNUMBER"/> <return-property name="htlNumber" column="HTLNUMBER"/> <return-property name="htlName" column="HTLNAME"/> <return-property name="ratNumber" column="RATNUMBER"/> <return-property name="staCode" column="STACODE"/> <return-property name="ctcEmail" column="CTCEMAIL"/> <return-property name="ctcFax" column="CTCFAX"/> <return-property name="preName" column="PRENAME"/> <return-property name="namName" column="NAMNAME"/> <return-property name="cntName" column="CNTNAME"/> <return-property name="worName" column="WORNAME"/> </return> { :toto = call S_RFPDISTRIAR :clientCode,:year,:status,:cntCode,:removeCCMSent } </sql-query> </hibernate-mapping>
Voici l'erreur :
Si je remplace :toto par ?, alors j'obtient ceci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 Caused by: org.hibernate.QueryException: Not all named parameters have been set: [toto] [{ :toto = call S_RFPDISTRIAR :clientCode,:year,:status,:cntCode,:removeCCMSent }] at org.hibernate.impl.AbstractQueryImpl.verifyParameters(AbstractQueryImpl.java:291) at org.hibernate.impl.SQLQueryImpl.verifyParameters(SQLQueryImpl.java:201) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:145) at org.springframework.orm.hibernate3.HibernateTemplate$33.doInHibernate(HibernateTemplate.java:940) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:369)
Merci d'avance pour vos futures réponses.
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 Caused by: java.sql.SQLException: JZ0SC: Callable Statement: attempt to set the return status as an input parameter. at com.sybase.jdbc2.jdbc.ErrorMessage.raiseError(ErrorMessage.java:569) at com.sybase.jdbc2.jdbc.ParamManager.setParam(ParamManager.java:380) at com.sybase.jdbc2.jdbc.SybPreparedStatement.setParam(SybPreparedStatement.java:1181) at com.sybase.jdbc2.jdbc.SybPreparedStatement.setParam(SybPreparedStatement.java:1174) at com.sybase.jdbc2.jdbc.SybPreparedStatement.setString(SybPreparedStatement.java:287) at org.apache.commons.dbcp.DelegatingPreparedStatement.setString(DelegatingPreparedStatement.java:132) at org.hibernate.type.StringType.set(StringType.java:26) at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:136) at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:116) at org.hibernate.loader.Loader.bindNamedParameters(Loader.java:1744) at org.hibernate.loader.Loader.bindParameterValues(Loader.java:1670) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1554) at org.hibernate.loader.Loader.doQuery(Loader.java:661) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224) at org.hibernate.loader.Loader.doList(Loader.java:2211) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2095) at org.hibernate.loader.Loader.list(Loader.java:2090) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289) at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695) at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152) at org.springframework.orm.hibernate3.HibernateTemplate$33.doInHibernate(HibernateTemplate.java:940) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:369)
Partager