Thanks for answering so quickly max,
you are right, i've replaced 1,2,3 by 0,1,2 like that
Code:
Query q =session.getNamedQuery("pContact")
.setInteger(0,1)
.setInteger(1,12)
.setString(2,"neige");
and then i replaced in the mapping file, the stored procedure call
Code:
? = call XX_StoredProc_GetPContact(?, ?, ?)
by :
Code:
call XX_StoredProc_GetPContact(?, ?, ?)
because the JDBC driver didn't recognize the first form.
I had to write a more specific Dialect, because i had the following error with the generic one :
Code:
java.lang.UnsupportedOperationException: org.hibernate.dialect.GenericDialect does not support resultsets via stored procedures.
at org.hibernate.dialect.Dialect.registerResultSetOutParameter(Dialect.java:791)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1175)
at org.hibernate.loader.Loader.doQuery(Loader.java:390)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:112)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1414)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:153)
at HibernateTest.main(HibernateTest.java:26)
I have just implemented the following methods in my dialect, and extend GenericDialect class:
Code:
package com.orkis.ajaris.hibernate.dialect;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.hibernate.dialect.GenericDialect;
public class J4DDialect extends GenericDialect {
public J4DDialect() {
super();
}
public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException {
statement.registerOutParameter(col, java.sql.Types.OTHER,"myResultSet");
return col++;
}
public ResultSet getResultSet(CallableStatement statement) throws SQLException {
statement.execute();
ResultSet rs = (ResultSet) statement.getObject(1);
return rs;
}
}
I have verified on the 4d server, the stored procedure is called, the 3 parameters are ok, and the procedure make its "work" and return the good result.
But the problem that I have now is that the
list() method returns a void list.
I think that the problem must come from the mapping, because i'm sure that myresultset is not empty. I have launched the test under eclipse in debug mode with breakpoints and i have seen the good values in the resulset.
So does someone has an idea?
thanks in advance