eduardo.leite wrote:
I realized that the problem might be the Driver.
I analysed the code with more caution, and I think that Hibernate is probabily doing the right thing.
I created a small example that opens a database connection using its datasource, creates a prepared statement, and then closes de connection.
The prepared statement, after its corresponding connection is closed, is also closed by the driver.
That's why I get an exception when hibernate tries to use the prepared statement after loading a proxy.
I will see if there is any driver setting that handles this behaviour.
Driver doe's the right thing in this case, all correct JDBC drivers must close open statements and resultsets after connection is closed.