Tried it on the hibernate forum but apparently my question is so trivial that it isn't even worth answering over there ;-)
So, I return: How do you call stored functions in the db from an entitymanager with hibernate? If I get the delegate and from the session a connection and use normal call syntax, the connection is closed and that causes grief for my SMPC.
If I embed the function call in a select statement then I can't do DML in the function :-/
Read chapter "11.3.2. Extended session and automatic versioning" of Seam Reference Manual Version 1.2.1 GA.
You can chance the flushMode of a session by calling:
Session s = (SessionImpl) entityManager.getDelegate(); s.setFlushMode(FlushMode.NEVER);
This prevents seam from closing the session automatically after the request finished
But you have to flush an close the session manually!
Ups! The mentioned chapter is in Hibernate reference documentation version 3.2.0 GA which is used in seam 1.2.1.
There is even a better way if you are working with annotations. See chapter 22.4. Annotations for context demarcation (Seam ref doc 1.2.1 - really ;-))
Just annotate the methode you are calling the SP with this annotation.
I'm already in a manual-flush-mode conversation.
And I've tried all of
getConversation().changeFlushMode(FlushModeType.MANUAL); and sessio.setFlushMode(FlushMode.MANUAL); and sessio.setFlushMode(FlushMode.NEVER); but it still insists on closing: [CachedConnectionManager] Closing a connection for you. Please close them yourself: org.jboss.resource.adapter.jdbc.WrappedConnection@18a9358
I have also played around with the hibernate properties in persistence.xml but no go.
I'd hate to tell the customers "Well, you can run *one* stored function and then you have to start the app again" ;-)
I tried setting hibernate.connection.release_mode to "after_statement", that didn't do anything. It reacted to "after_transaction" by not closing the connection immediately, unfortunately seam itself closed it (at the end of the current long running conversation?) so that was a no-go either :-/
In other words: should I just give up and start fresh from the JNDI or is there a way of getting a connection from an entitymangager, run a stored procedure and just happily live on?