Hello
I’m afraid I don’t understand a lifecycle of PreparedStatements cached by connection pool (for example c3p0).
Let assume that we have a first database session.
This session is querying a database using a following SQL: SELECT ID FROM TABLE
Hibernate will generate a PreparedStatement for this query.
Question 1Is this prepared statement can be reused and can be shared by other database sessions?
Question 2Let assume that my first session is broken (network error for example). Then this session will be closed by Hibernate (or c3p0) due to fatal error occurred for this particular session.
What will happen with all prepared statements created by my first session?
Will all PreparedStatements will be destroyed too during closing this first session?
Or maybe PreparedStatements can live longer than session which created this PreparedStatements?
Kind regards,
Adam
PS.
This question is related to JDBC Statements / PreparedStatements performance consideration described in this article:
Java Programming with Oracle JDBC - Chapter 19 Performance
http://oreilly.com/catalog/jorajdbc/chapter/ch19.htmlPS II.
This is related to Hibernate setting:
hibernate.c3p0.max_statements