diff --git a/reference/en/modules/query_sql.xml b/reference/en/modules/query_sql.xml index dbbc5086e3..e4c4a535d0 100644 --- a/reference/en/modules/query_sql.xml +++ b/reference/en/modules/query_sql.xml @@ -234,6 +234,31 @@ BEGIN Notice stored procedures currently only return scalars and entities. >return-join< and >load-collection< is not supported. + + + TODO: make the "rules" visually nicer and understandable ,) + + + + Rules/Limitations for using stored procedures + + + To use stored procedures with Hibernate the procedures have to follow some rules. If they do not follow those + rules they are not usable with Hibernate. If you still want to use these procedures you have to execute them via session.connection(). + + The rules are different per database since database vendors have different stored procedure semantics/syntax. + + For Oracle the following rules applies: + + 1. It must return a result set. (This is done by returning a SYS_REFCURSOR in Oracle 9 & 10, in Oracle you need to define a REF CURSOR type) + 2. It should be on the form { ? = call procName() } or { ? = call procName} (this is more a Oracle rule than a Hibernate rule) + + For Sybase & MS SQL server the following rules applies: + + It must return a result set. Note that since these servers can/will return multiple result sets and update count Hibernate will iterate the results and take the first result that is a result set as its return value. Everything else will be discarded. + If you can enable SET NOCOUNT ON in your procedure it will probably be the most efficient, but it is not an requirement. + +