-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Bulk Inserts java.lang.StackOverflowError
PostPosted: Sat Mar 04, 2006 5:50 pm 
Newbie

Joined: Fri Oct 17, 2003 6:11 am
Posts: 15
Hibernate version:
3.1
Mapping documents:
..
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
default-cascade="save-update"
package="hbmgenerated.it.tinvention.dao"
schema="gordini"
>

<!-- Users -->
<class name="Utente" >
<id type="java.lang.Long" name="id" >
<column name="id" />
<generator class="native" />
</id>
<property type="string" name="username" unique="true" />
<property type="string" name="passwordName" />
<property type="string" name="role" /> <!-- eg "root" or "manager" for sermoneta persons, or null for agenti -->
<property type="string" name="name" />
<property type="string" name="surName" />
<property type="string" name="email" />

<joined-subclass name="Agente" >
<key column="id" on-delete="cascade" not-null="true" />

<property type="string" name="phone" />
<property type="string" name="mobile" />
<property type="string" name="city" />
<property type="string" name="address" />
<property type="string" name="province" />
<property type="string" name="notes" />

<set name="clienti" inverse="true" >
<key column="agenteId" />
<one-to-many class="Cliente" />
</set>

</joined-subclass>
</class>

<!-- Clienti -->
<class name="Cliente" >
<id type="java.lang.Long" name="id" >
<column name="id" />
<generator class="native" />
</id>

<many-to-one name="agente" class="Agente" column="agenteId" />

<property type="string" name="name" />
<property type="string" name="codiceFiscale" />
<property type="string" name="piva" />
<property type="string" name="email" />
<property type="string" name="phone" />
<property type="string" name="fax" />

<!-- Fatturazione -->
<property type="string" name="city" />
<property type="string" name="address" />
<property type="string" name="cap" />
<property type="string" name="province" />
<property type="string" name="notes" />

<!-- Consegna -->
<property type="string" name="cityConsegna" />
<property type="string" name="addressConsegna" />
<property type="string" name="capConsegna" />
<property type="string" name="provinceConsegna" />
<property type="string" name="notesConsegna" />
</class>

<!-- Reminder -->
<class name="Reminder" >
<id type="java.lang.Long" name="id" >
<column name="id" />
<generator class="native" />
</id>
<property type="string" name="subject" />
<property type="string" name="body" />
<property type="boolean" name="sent" />
<property type="date" name="expire" />
<property type="string" name="email" />
<one-to-one class="OrdineIngresso" name="ordine" property-ref="reminder"/>
</class>

<!-- Fornitori -->
<class name="Fornitore" >
<id type="java.lang.Long" name="id" >
<column name="id" />
<generator class="native" />
</id>
<property type="string" name="name" />
<property type="string" name="email" />
<property type="string" name="phone" />
<property type="string" name="city" />
<property type="string" name="address" />
<property type="string" name="province" />
<property type="string" name="notes" />

<set name="modelli" inverse="true" >
<key column="fornitoreId" />
<one-to-many class="Modello" />
</set>

</class>


<!-- Varianti disponibili, es. guanti modello giuditta, rossi, large-->
<class name="Variante" >
<id type="java.lang.Long" name="id" >
<column name="id" />
<generator class="native" />
</id>

<property type="string" name="name" />

<many-to-one name="taglia" class="Taglia" />
<many-to-one name="colore" class="Colore" />
<many-to-one name="modello" class="Modello" column="varianteId" not-null="true" />

</class>

<!-- Modello disponibile es. modello giuditta-->
<class name="Modello" >
<id type="java.lang.Long" name="id" >
<column name="id" />
<generator class="native" />
</id>

<property type="string" name="name" not-null="true" unique="true" />
<property type="string" name="descrizione" />

<many-to-one name="fornitore" class="Fornitore" column="fornitoreId" not-null="true" />

<set name="varianti" inverse="true" >
<key column="varianteId" />
<one-to-many class="Variante" />
</set>

</class>

<!-- Taglie Modelli disponibili-->
<class name="Taglia" >
<id type="java.lang.Long" name="id" >
<column name="id" />
<generator class="native" />
</id>

<property type="string" name="name" not-null="true" unique="true" />
<property type="string" name="descrizione" />

</class>

<!-- Colori Modelli disponibili-->
<class name="Colore" >
<id type="java.lang.Long" name="id" >
<column name="id" />
<generator class="native" />
</id>
<property type="string" name="descrizione" />
<property type="string" name="name" not-null="true" unique="true" />

</class>

<class name="RigaOrdine" >
<id type="java.lang.Long" name="id" >
<column name="id" />
<generator class="native" />
</id>
<property name="quantita" type="java.lang.Integer" />
<property name="consegnata" type="java.lang.Boolean" />

<many-to-one class="Variante" name="variante" />
<many-to-one name="ordineIn" column="ordInId" class="OrdineIngresso" not-null="true"/>

<!-- Se null non ancora inserita in un oridne di uscita -->
<many-to-one name="ordineOut" column="ordOutId" class="OrdineUscita" not-null="false"/>
</class>


<!-- Ordini Ingresso -->
<class name="OrdineIngresso" >
<id type="java.lang.Long" name="id" >
<column name="id" />
<generator class="native" />
</id>
<property type="java.util.Date" name="data" />
<property type="string" name="stato" />

<set name="righe" inverse="true" >
<key column="ordInId" />
<one-to-many class="RigaOrdine"/>
</set>

<many-to-one name="cliente" class="Cliente" column="clienteId" not-null="true" />

<many-to-one name="reminder" class="Reminder"
column="reminderId"
unique="true"
not-null="false"/>

</class>

<!-- Ordini Uscita -->
<class name="OrdineUscita" >
<id type="java.lang.Long" name="id" >
<column name="id" />
<generator class="native" />
</id>
<property type="string" name="stato" /><!-- new, inprocess, delivered, ... -->
<property type="string" name="etichetta" />
<property type="string" name="note" />
<property type="string" name="luogo" />
<property type="java.util.Date" name="consegna" />

<set name="righe" inverse="true" >
<key column="ordOutId" not-null="true" />
<one-to-many class="RigaOrdine"/>
</set>

<many-to-one name="fornitore" class="Fornitore" column="fornitoreId" not-null="true" />

</class>



</hibernate-mapping>

...
Code between sessionFactory.openSession() and session.close():
..
int numberofItems = 40;
HibernateUtil.getSessionFactory().getCurrentSession().beginTransaction();
List colori = new ArrayList();
List taglie = new ArrayList();
for (int i=0;i<numberofItems;i++) {

final Colore greenGrass = new Colore();
greenGrass.setName("colorAuto"+i);
PersistedObjectManager.persist(greenGrass);
colori.add(greenGrass);

final Taglia taglia = new Taglia();
taglia.setName("autoTaglia"+i);
PersistedObjectManager.persist(taglia);
taglie.add(taglia);

log.debug("Current color and taglia added");
}
HibernateUtil.getSessionFactory().getCurrentSession().flush();
HibernateUtil.getSessionFactory().getCurrentSession().clear();
HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().commit();
..
Full stack trace of any exception that occurs:
[java] Exception in thread "main" java.lang.StackOverflowError
[java] at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:188)
[java] at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1900)
[java] at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2349)
[java] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2860)
[java] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:771)
[java] at com.mysql.jdbc.MysqlIO.nextRow(MysqlIO.java:1289)
[java] at com.mysql.jdbc.MysqlIO.readSingleRowSet(MysqlIO.java:2259)
[java] at com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:423)
[java] at com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:1960)
[java] at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:1385)
[java] at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1138)
[java] at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:675)
[java] at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1027)
[java] at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
[java] at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
[java] at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
[java] at org.hibernate.loader.Loader.doQuery(Loader.java:662)
[java] at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
[java] at org.hibernate.loader.Loader.doList(Loader.java:2150)
[java] at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
[java] at org.hibernate.loader.Loader.list(Loader.java:2024)
[java] at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
[java] at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1550)
[java] at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:298)
......
Name and version of the database you are using:
5.0 Mysql
The generated SQL (show_sql=true):
[java] Hibernate:
[java] select
[java] this_.id as id9_0_,
[java] this_.quantita as quantita9_0_,
[java] this_.consegnata as consegnata9_0_,
[java] this_.variante as variante9_0_,
[java] this_.ordInId as ordInId9_0_,
[java] this_.ordOutId as ordOutId9_0_
[java] from
[java] gordini.RigaOrdine this_
[java] Hibernate:
[java] select
[java] this_.id as id11_0_,
[java] this_.stato as stato11_0_,
[java] this_.etichetta as etichetta11_0_,
[java] this_.note as note11_0_,
[java] this_.luogo as luogo11_0_,
[java] this_.consegna as consegna11_0_,
[java] this_.fornitoreId as fornitor7_11_0_
[java] from
[java] gordini.OrdineUscita this_
... generate 3 MB of sql text output ..

Others interested hbm.properties:
hibernate.default_batch_fetch_size 500
hibernate.jdbc.batch_size 5000

Any Ideas ?
I've used also a StatelessSession but the same error occur.....

Bye
Stefano


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 06, 2006 12:16 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
You've left out all the important bits: the rest of the stack trace (so we can figure out where your code is going wrong: all you've shown us is hibernate and jdbc parts of the trace), and the criteria that you're running (your trace "starts" in CriteriaImpl, but your source code doesn't mention Crtieria anywhere). Can you post that stuff?

One thing you might try before that is to remove references to Agente, except when defining the class. As far as I know, you have to refer to the superclass when referring to a joined-sublcass. It's a bug, of sorts; it may be possible to do what you're doing in Cliente's "agente" many-to-one, but I don't think that it is (yet).

Also, please use code tags when posting code here. Left-aligned proportional typefaces make it very hard to read code.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.