[Hibernate-JIRA] Created: (HHH-2734) PreparedStatement leak with lazy properties
by Christian Gruber (JIRA)
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
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....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
17 years, 2 months
[Hibernate-JIRA] Commented: (HHH-1334) Implements query.setParameterList(int position, Collection vals)
by John Newman (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1334?page=c... ]
John Newman commented on HHH-1334:
----------------------------------
Hi,
I also have this requirement,
for (int i = 0; i < queryArgs.lengh; ++i) {
if (Collection.class.isAssignableFrom(queryArgs[i].getClass()) {
query.setParameterList(i, (Collection) queryArgs[i]); // would work but this method doesn't exist for reason above
} else {
query.setParameter(i, queryArgs[i]);
}
}
now since we won't be seeing that method, I could do:
String[] paramNames = query.getParameterNames();
for (int i = 0; i < queryArgs.lengh; ++i) {
if (Collection.class.isAssignableFrom(queryArgs[i].getClass()) {
query.setParameterList(parameterNames[i], (Collection) queryArgs[i]); // would work but the param names are not in the correct order.
} else {
query.setParameter(i, queryArgs[i]);
}
}
so I figure typically when you have something in a map that is out of order, you can just use a LinkedHashMap to keep the order straight. Looking around here, (god hibernate is complicated) I found what I think to be the source, line 290 of HQLQueryPlan:
Map namedParamDescriptorMap = new HashMap();
Just taking a stab at it I wonder if switching that to LinkedHashMap would do the trick? If those params can come out in the order they appear in the query, setParameterList(i, o) should be possible.
But I don't think that would cover the case of mixed named & ordinal params : query="FROM X where y = ? and z = ? and list = :list and q = ? ...
thoughts?
> Implements query.setParameterList(int position, Collection vals)
> ----------------------------------------------------------------
>
> Key: HHH-1334
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1334
> Project: Hibernate3
> Issue Type: Improvement
> Components: core
> Affects Versions: 3.1
> Reporter: Emmanuel Bernard
>
> This is expected by EJB3
--
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....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
17 years, 2 months
[Hibernate-JIRA] Created: (EJB-317) Include cause in rollback exceptions
by James Olsen (JIRA)
Include cause in rollback exceptions
------------------------------------
Key: EJB-317
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-317
Project: Hibernate Entity Manager
Issue Type: Improvement
Components: EntityManager
Affects Versions: 3.3.1.GA
Reporter: James Olsen
Attachments: ejb.patch
Some J2EE Servers fail fast following a call to setRollbackOnly() during commit processing and return an UnexpectedRollbackException or similar. There is currently no way for the caller to determine why the transaction was rolled back.
The attached patch makes use of the proprietary WLS setRollbackOnly(Throwable) method when available to ensure the cause (duplicate key, optimistic lock etc) can be returned to the caller.
In addition the patch includes a mechanism for translating the cause if desired (e.g. to map to an application defined exception hierarchy) as the commit flow is running in container code so there is no way to wrap it from the outside.
--
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....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
17 years, 2 months
[Hibernate-JIRA] Updated: (HBX-446) one-to-many relation with not-null attribute on key element
by Max Rydahl Andersen (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HBX-446?page=co... ]
Max Rydahl Andersen updated HBX-446:
------------------------------------
Fix Version/s: (was: 3.2.beta11)
3.2.beta12
> one-to-many relation with not-null attribute on key element
> -----------------------------------------------------------
>
> Key: HBX-446
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-446
> Project: Hibernate Tools
> Issue Type: Bug
> Components: hbm2java
> Environment: 3.x
> Reporter: Sreeram Katta
> Priority: Critical
> Fix For: 3.2.beta12
>
>
> one-to-many relation with not-null attribute on key element is throwing below error when I run the hbm2java tool. I have a base class with a joined-subclass and the joined subclass has one-to-many relationship with another class. The one-to-many uses a list. When I specify not-null attribute on the key element in the relationship I get the below error. If I remove it I don't get this error. If I let the key stay not-null, during run time persistence fails. So I had to revert the mapping file at runtime for the persistence to go fine. It is only the tool that is misbehaving.
> ----------------> Error
> org.hibernate.tool.hbm2x.ExporterException: Error while processing t
> emplate pojo/javaclass.vm
> at org.apache.tools.ant.Task.perform(Task.java:373)
> at org.apache.tools.ant.Target.execute(Target.java:341)
> at org.apache.tools.ant.Target.performTasks(Target.java:369)
> at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
> at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
> at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
> at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
> at org.apache.tools.ant.Main.runBuild(Main.java:668)
> at org.apache.tools.ant.Main.startAnt(Main.java:187)
> at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
> at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
> Caused by: org.hibernate.tool.hbm2x.ExporterException: Error while processing template pojo/javaclass.vm
> at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelper.java:89)
> at org.hibernate.tool.hbm2x.POJOExporter.runVelocity(POJOExporter.java:78)
> at org.hibernate.tool.hbm2x.POJOExporter.exportPersistentClass(POJOExporter.java:61)
> at org.hibernate.tool.hbm2x.POJOExporter.start(POJOExporter.java:111)
> at org.hibernate.tool.ant.GeneratorTask.execute(GeneratorTask.java:33)
> at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:115)
> at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
> at org.apache.tools.ant.Task.perform(Task.java:364)
> -----------------
> mapping files
> -----------> Base class
> <?xml version="1.0"?>
> <!DOCTYPE hibernate-mapping PUBLIC
> "-//Hibernate/Hibernate Mapping DTD//EN"
> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
> <hibernate-mapping package="test.resources.core">
> <class
> name="Resource"
> table="Resource" polymorphism="explicit"
> >
> <id
> name="Id"
> type="integer"
> column="resourceId"
> >
> <meta attribute="use-in-equals">true</meta>
> <generator class="hilo">
> <param name="table">ResourceIdTracker</param>
> <param name="column">resourceId</param>
> </generator>
> </id>
> <property
> name="ResourceName"
> column="resourceName"
> type="string"
> not-null="true"
> length="80"
> />
> <property
> name="ResourceDescription"
> column="resourceDescription"
> type="string"
> not-null="true"
> length="255"
> />
> <property
> name="ResourceTypeId"
> column="resourceTypeId"
> type="integer"
> not-null="true"
> length="10"
> />
> <property
> name="CreatedBy"
> column="createdBy"
> type="integer"
> not-null="true"
> length="10"
> />
> <property
> name="CreatedTime"
> column="createdTime"
> type="timestamp"
> not-null="true"
> length="23"
> />
> <property
> name="LastUpdatedBy"
> column="lastUpdatedBy"
> type="integer"
> not-null="true"
> length="10"
> />
> <property
> name="LastUpdatedTime"
> column="lastUpdatedTime"
> type="timestamp"
> not-null="true"
> length="23"
> />
> <property
> name="Deleted"
> column="deleted"
> type="string"
> not-null="true"
> length="1"
> />
> <set name="ResourcePermissions" table="ResourcePermission" inverse="true">
> <key column="resourceId" not-null="true"/>
> <one-to-many class="ResourcePermission"/>
> </set>
> </class>
> </hibernate-mapping>
> --------------------> JOINED SUBCLASS
> <?xml version="1.0"?>
> <!DOCTYPE hibernate-mapping PUBLIC
> "-//Hibernate/Hibernate Mapping DTD//EN"
> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
> <hibernate-mapping package="test.resources.chartbook">
> <joined-subclass
> name="ChartDefinition"
> table="ChartDefinition"
> extends="test.resources.core.Resource"
> >
> <key column="chartDefinitionId"/>
> <property
> name="FromDate"
> column="fromDate"
> type="integer"
> not-null="false"
> length="10"
> />
> <property
> name="ToDate"
> column="toDate"
> type="integer"
> not-null="false"
> length="10"
> />
> <property
> name="Period"
> column="period"
> type="string"
> not-null="false"
> length="32"
> />
> <property
> name="ViewType"
> column="viewType"
> type="string"
> not-null="false"
> length="32"
> />
> <!-- This works but requires bidrecitional setting -->
> <one-to-one name="chartAxisDefinition" cascade="all-delete-orphan" class="ChartAxisDefinition"/>
> <!-- having a not-null attribute on key is thowing error while generating classes where as -->
> <!-- not having it is throwing an error while inserting -->
> <!-- for now removing while code generation and adding it back while run time -->
> <!-- NEED TO ADDRESS THIS -->
> <list name="ChartSeries" cascade="all-delete-orphan" inverse="false" lazy="false">
> <key column="chartDefinitionId" not-null="true"/>
> <list-index column="position" />
> <one-to-many class="ChartSeries"/>
> </list>
> </joined-subclass>
> </hibernate-mapping>
> --------------> ONE TO MANY TARGET
> <?xml version="1.0"?>
> <!DOCTYPE hibernate-mapping PUBLIC
> "-//Hibernate/Hibernate Mapping DTD//EN"
> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
> <hibernate-mapping package="test.resources.chartbook">
> <class
> name="ChartSeries"
> table="ChartSeries"
> >
> <id
> name="Id"
> type="integer"
> column="chartSeriesId"
> >
> <generator class="hilo">
> <param name="table">ResourceIdTracker</param>
> <param name="column">resourceId</param>
> </generator>
> </id>
> <property
> name="Included"
> column="included"
> type="string"
> not-null="true"
> length="1"
> />
> <property
> name="SelectorTreeNodePath"
> column="selectorTreeNodePath"
> type="string"
> not-null="false"
> length="1024"
> />
> <property
> name="Attribute"
> column="attribute"
> type="string"
> not-null="false"
> length="50"
> />
> <property
> name="ColumnName"
> column="columnName"
> type="string"
> not-null="false"
> length="255"
> />
> <property
> name="Formula"
> column="formula"
> type="string"
> not-null="false"
> />
> <property
> name="AxisLocation"
> column="axisLocation"
> type="string"
> not-null="true"
> length="32"
> />
> <property
> name="Position"
> column="position"
> type="integer"
> not-null="true"
> length="10"
> insert="false"
> update="false"
> />
> </class>
> </hibernate-mapping>
> -------------- ONE TO ONE TARGET
> <?xml version="1.0"?>
> <!DOCTYPE hibernate-mapping PUBLIC
> "-//Hibernate/Hibernate Mapping DTD//EN"
> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
> <hibernate-mapping package="test.resources.chartbook">
> <class
> name="ChartAxisDefinition"
> table="ChartAxisDefinition"
> >
> <id
> name="Id"
> type="integer"
> column="chartAxisDefinitionId"
> >
> <generator class="foreign">
> <param name="property">ChartDefinition</param>
> </generator>
> </id>
> <property
> name="LeftAxisMin"
> column="leftAxisMin"
> type="java.lang.Double"
> not-null="true"
> length="15"
> />
> <property
> name="LeftAxisMax"
> column="leftAxisMax"
> type="java.lang.Double"
> not-null="true"
> length="15"
> />
> <property
> name="RightAxisMin"
> column="rightAxisMin"
> type="java.lang.Double"
> not-null="true"
> length="15"
> />
> <property
> name="RightAxisMax"
> column="rightAxisMax"
> type="java.lang.Double"
> not-null="true"
> length="15"
> />
> <property
> name="LeftAxisLabel"
> column="leftAxisLabel"
> type="string"
> not-null="true"
> length="32"
> />
> <property
> name="RightAxisLabel"
> column="rightAxisLabel"
> type="string"
> not-null="true"
> length="32"
> />
> <property
> name="ChartName"
> column="chartName"
> type="string"
> not-null="true"
> length="80"
> />
> <one-to-one name="ChartDefinition" class="ChartDefinition" constrained="true"/>
> </class>
> </hibernate-mapping>
--
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....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
17 years, 2 months