Wednesday, July 16, 2008

Doing StoredProcedures as NamedQueries in Hibernate and JPA Java Persistence API or EJB3.0

Here are some wise words of wisdom regarding stored procedures and Hibernate from Mark Spritzler from the JavaRanch:

In Hibernate there are some caveats to stored procedures.

1. Only one out parameter and it must be the first parameter
2. The out parameter must be a refcursor. No other types will work.

If you have to work with a stored procedure that returns a varchar, you can call session.getConnection() and work directly with the jdbc connection. Although in this case you can't use a named query.

No comments: