[hibernate-issues] [Hibernate-JIRA] Resolved: (HHH-2734) PreparedStatement leak with lazy properties

Gail Badner (JIRA) noreply at atlassian.com
Thu Oct 4 17:53:25 EDT 2007


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2734?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gail Badner resolved HHH-2734.
------------------------------

      Assignee: Gail Badner
    Resolution: Duplicate

> PreparedStatement leak with lazy properties
> -------------------------------------------
>
>                 Key: HHH-2734
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2734
>             Project: Hibernate3
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.4
>         Environment: Hibernate 3.2.4
> Oracle 10g
> Sun Java 1.5.0
>            Reporter: Christian Gruber
>            Assignee: Gail Badner
>            Priority: Critical
>
> Hello!
> When iterating through more than 300 elements that have lazy properties, I get an ORA-01000 JDBC error ("maximum open cursors exceeded"). I found out that the root cause for this are unclosed prepared statements in AbstractBatcher.prepareSelectStatement(String). When I add the generated prepared statement to the statementsToClose set in this method, the problem vanishes. But I don't have an idea what other effects this might have, and why the prepared statement was not added to the statements to close in the first place.
> How to reproduce:
> - Make a class with at least one lazy property; instrument the byte code
> - Create an Oracle database with at least 300 entries in the table for this class
> - Execute the following code:
> Iterator<MyClass> it = session.createQuery("from MyClass mc").iterate();
> while (it.hasNext()) {
>     MyClass mc = it.next();
>     String la = mc.getLazyAttribute();
>     session.evict(mc);
> }
> - Watch the log for org.hibernate.jdbc.AbstractBatcher entries containing
>   "about to open ResultSet" and see the numbers increase
> As already mentioned, a simple fix for this is adding "statementsToClose.add( ps );" into AbstractBatcher.java, around line 133 (assigning the PreparedStatement to a new variable "ps" first, of course), but as I don't understand the differences between the various PreparedStatement generating methods there, that might give rise to other problems.
> Thanks for looking at it,
> Christian

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list