When creating more as 300 Object in Oracle with insert="false" and generated="insert" by property - Tag in Mapping-File
causes an ORA-01000 "too many open cursors"...
It is executed using the following Java code:
SessionFactory sessionFactory;
try {
// Create the SessionFactory from hibernate.cfg.xml
sessionFactory = new Configuration().
configure().
buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
try{
for (int i = 0; i <= 301; i++) {
Session session = sessionFactory.getCurrentSession();
Transaction tx = session.beginTransaction();
Test test = new Test();
session.save(test);
tx.commit();
}
} catch (Exception e) {
System.out.println(e.getMessage()+e.getClass().toString());
}
And Mapping - File:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"
http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<class
name="src.persistence.Test"
table="TEST"
>
<id name="id" type="java.lang.Long" column="ID"
>
<generator class="sequence">
<param name="sequence">TEST_SEQ</param>
</generator>
</id>
<property
name="created"
column="CREATED"
type="java.util.Date"
not-null="true"
insert="false"
update="false"
generated="insert"
>
</property>
</class>
</hibernate-mapping>
The attached patch is applicable against 3.1.3. It works for me.