Hibernate version:
latest
Mapping documents:
Code:
<?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 package="iwp.baseline.data.orm">
<class name="Segmentation" table="BinderyTypeSizeAndWeightSegmentation"
lazy="false">
<id name="id" column="binderySizeWeightSegmentationID">
<generator class="native" />
</id>
<property name="maxSheetSize" column="SheetSizeSegmentation" type="float" />
<many-to-one name="maxPaperWeight" column="fk_paperWeightSegmentation" class="PaperWeight"/>
<many-to-one name="binderyFunction" column="fk_binderyTypeID" class="BinderyFunction"/>
<set name="binderyCosts" lazy="false"
inverse="true" cascade="all-delete-orphan,merge">
<key column="fk_binderySizeWeightSegmentationID"/>
<one-to-many class="BinderyFunctionCost"/>
</set>
</class>
</hibernate-mapping>
and
Code:
<?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 package="iwp.baseline.data.orm">
<class name="BinderyFunctionCost" table="BinderyTypeCostPer1000" lazy="false">
<composite-id>
<key-many-to-one name="segmentation" class="Segmentation" column="fk_binderySizeWeightSegmentationID" />
<key-many-to-one name="region" class="Region" column="fk_regionID" />
<key-property name="quantitySegmentation" column="QuantitySegmentation" type="int" />
</composite-id>
<property name="costPerThousand" column="CostPer1000" type="float" />
<property name="makeReadyCost" column="MakeReadyCost" type="float" />
<property name="makeReadySpoilage" column="MakeReadySpoilage" type="int" />
<property name="runSpoilage" column="RunSpoilageRate" type="float" />
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
Session session = getCurrentSession();
Transaction t = session.beginTransaction();
for (AbstractPersistentEntity<?> pe : set) {
try {
session.merge(pe);
} catch (NonUniqueObjectException nuoe) {
System.out.println("NUOE: " + nuoe.getIdentifier());
session.merge(pe);
}
}
try {
t.commit();
} catch (Exception e) {
t.rollback();
e.printStackTrace();
}
Full stack trace of any exception that occurs:Code:
java.lang.StackOverflowError
at net.sourceforge.jtds.jdbc.JtdsStatement.<init>(JtdsStatement.java:129)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.<init>(JtdsPreparedStatement.java:96)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.prepareStatement(ConnectionJDBC2.java:2221)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.prepareStatement(ConnectionJDBC2.java:2179)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:505)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:423)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547)
at org.hibernate.loader.Loader.doQuery(Loader.java:673)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1860)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3049)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:399)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:179)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:846)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:557)
at org.hibernate.type.EntityType.resolve(EntityType.java:379)
at org.hibernate.type.ComponentType.resolve(ComponentType.java:584)
at org.hibernate.type.ComponentType.nullSafeGet(ComponentType.java:275)
at org.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:1097)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:565)
at org.hibernate.loader.Loader.doQuery(Loader.java:701)
{snip - it repeats most of the above over and over}
Name and version of the database you are using:MSSQL Server 9.0
The generated SQL (show_sql=true):Code:
-- this line is repeated several hundred times
Hibernate: select segmentati0_.binderySizeWeightSegmentationID as binderyS1_20_1_, segmentati0_.SheetSizeSegmentation as SheetSiz2_20_1_, segmentati0_.fk_paperWeightSegmentation as fk3_20_1_, segmentati0_.fk_binderyTypeID as fk4_20_1_, binderycos1_.fk_binderySizeWeightSegmentationID as fk1_3_, binderycos1_.fk_regionID as fk2_3_, binderycos1_.QuantitySegmentation as Quantity3_3_, binderycos1_.fk_binderySizeWeightSegmentationID as fk1_19_0_, binderycos1_.fk_regionID as fk2_19_0_, binderycos1_.QuantitySegmentation as Quantity3_19_0_, binderycos1_.CostPer1000 as CostPer4_19_0_, binderycos1_.MakeReadyCost as MakeRead5_19_0_, binderycos1_.MakeReadySpoilage as MakeRead6_19_0_, binderycos1_.RunSpoilageRate as RunSpoil7_19_0_ from BinderyTypeSizeAndWeightSegmentation segmentati0_ left outer join BinderyTypeCostPer1000 binderycos1_ on segmentati0_.binderySizeWeightSegmentationID=binderycos1_.fk_binderySizeWeightSegmentationID where segmentati0_.binderySizeWeightSegmentationID=?
Debug level Hibernate log excerpt:
none available
Any ideas? It might be that I am setting up the merge relationship incorrectly.