I thought that I'd raise this as it may save somebody else the time that I wasted looking for an answer elsewhere.
I had my first requirement to access stored procedures, via Hibernate, yesterday and based my evaluation code upon the online documentaion example (to be found at
http://www.hibernate.org/hib_docs/v3/reference/en/html/querysql.html#sp_query)...
Code:
<sql-query name="selectAllEmployees_SP" callable="true">
<return alias="emp" class="Employment">
<return-property name="employee" column="EMPLOYEE"/>
<return-property name="employer" column="EMPLOYER"/>
<return-property name="startDate" column="STARTDATE"/>
<return-property name="endDate" column="ENDDATE"/>
<return-property name="regionCode" column="REGIONCODE"/>
<return-property name="id" column="EID"/>
<return-property name="salary">
<return-column name="VALUE"/>
<return-column name="CURRENCY"/>
</return-property>
</return>
{ ? = call selectAllEmployments() }
</sql-query>
I dutifully modified the names of the procedure/class/field/columns to suit my purposes and fired up the testcases.
The error that I received was as follows...
Code:
[ERROR] 58:10 (JDBCExceptionReporter.java:logExceptions:72)
Parameter #1 has not been set.
Due to the relative newness of Stored Procedure support in Hibernate and the subsequent sparse documentation, I couldn't really figure out how to resolve this issue.
Quite a bit of searching on the web resulted in me finding another example mapping file that made me realise how stupid I'd been - the opening '? =' was not required at all!
The online documentation should, in fact, read...
Code:
...
{ call selectAllEmployments() }
...
Could somebody update the docs, to prevent others from the same head scratching?
Yes, I know how stupidly obvious the solution is but - as always - it's only obvious when you know the answer!