Hibernate version: 3.0.3
Name and version of the database you are using: MySql
Mapping documents:
<class name="vo.sku.SkuCost" table="skucost">
<composite-id>
<key-property name="skuId" column="skuId" length="50" type="string"/>
<key-property name="status" column="status" length="1" type="string"/>
<key-property name="effectiveFrom" column="effectiveFrom" type="java.util.Date"/>
</composite-id>
<property name="cost" column="cost" type="java.lang.Double"/>
<property name="postage" column="postage" type="java.lang.Double"/>
<property name="effectiveTo" column="effectiveTo" type="java.util.Date"/>
</class>
<class name="vo.sku.OwnSku" table="sku">
<id name="skuId" column="skuId" type="string" length="15">
<generator class="assigned"/>
</id>
<property name="title" column="title" type="string" length="150" not-null="true"/>
<property name="description" column="description" type="string"/>
<property name="picUrl" column="picUrl" length="150" type="string"/>
<property name="brand" column="brand" length="50" type="string"/>
<property name="model" column="model" length="50" type="string"/>
<property name="productType" column="productType" length="20" type="string"/>
<property name="supplyType" column="supplyType" length="1" type="string" not-null="true"/>
<property name="status" column="status" length="1" type="string" not-null="true"/>
<property name="groupId" column="groupId" length="50" type="string"/>
<set name="costs" table="skucost" inverse="true" lazy="true" cascade="all-delete-orphan" order-by="effectiveFrom desc" >
<key>
<column name="skuId"/>
</key>
<one-to-many class="vo.sku.SkuCost"/>
</set>
</class>
Code between sessionFactory.openSession() and session.close():
I'm using Spring:
public class OwnSkuDaoTarget extends HibernateDaoSupport implements OwnSkuDao {
...
public void storeSku(OwnSku sku) throws DataAccessException {
getHibernateTemplate().merge(sku);
}
...
}
with Test case:
public void testCascadeInsert() {
OwnSku newSku = new OwnSku();
newSku.setSkuId("test1");
newSku.setTitle("testing");
newSku.setStatus(Sku.Status.ACTIVE);
newSku.setSupplyType(Sku.SELF_OWN);
newSku.setCosts(new HashSet());
SkuCost cost = new SkuCost();
cost.setSkuId(newSku.getSkuId());
cost.setStatus(SkuCost.Status.ACTIVE);
cost.setEffectiveFrom(Calendar.getInstance().getTime());
cost.setCost(new Double(500));
cost.setPostage(new Double(1));
newSku.getCosts().add(cost);
OwnSkuDao skuDao = (OwnSkuDao) this.context.getBean("ownSkuDao");
skuDao.storeSku(newSku);
assertTrue(true);
}
Full stack trace of any exception that occurs:
java.sql.BatchUpdateException occured due to missing identifier column in the insert statement of the skuCost object.
It seems the merge module "lost" the identifier column after trying to retrieve it from database.
Debug level Hibernate log excerpt:
11:33:11,524 - DEBUG org.hibernate.impl.SessionImpl - opened session at timestamp: 4632530089955328
11:33:11,540 - DEBUG org.hibernate.engine.Cascades - id unsaved-value strategy UNDEFINED
11:33:11,540 - DEBUG org.hibernate.event.def.AbstractSaveEventListener - detached instance of: vo.sku.OwnSku
11:33:11,540 - DEBUG org.hibernate.event.def.DefaultMergeEventListener - merging detached instance
11:33:11,540 - DEBUG org.hibernate.event.def.DefaultLoadEventListener - loading entity: [vo.sku.OwnSku#test1]
11:33:11,540 - DEBUG org.hibernate.event.def.DefaultLoadEventListener - attempting to resolve: [vo.sku.OwnSku#test1]
11:33:11,540 - DEBUG org.hibernate.event.def.DefaultLoadEventListener - object not resolved in any cache: [vo.sku.OwnSku#test1]
11:33:11,540 - DEBUG org.hibernate.persister.entity.BasicEntityPersister - Materializing entity: [vo.sku.OwnSku#test1]
11:33:11,540 - DEBUG org.hibernate.loader.Loader - loading entity: [vo.sku.OwnSku#test1]
11:33:11,540 - DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
11:33:11,540 - DEBUG org.hibernate.jdbc.AbstractBatcher - opening JDBC connection
11:33:11,540 - DEBUG org.hibernate.SQL - select ownsku0_.skuId as skuId0_, ownsku0_.title as title1_0_, ownsku0_.description as descript3_1_0_, ownsku0_.picUrl as picUrl1_0_, ownsku0_.brand as brand1_0_, ownsku0_.model as model1_0_, ownsku0_.productType as productT7_1_0_, ownsku0_.supplyType as supplyType1_0_, ownsku0_.status as status1_0_, ownsku0_.groupId as groupId1_0_ from sku ownsku0_ where ownsku0_.skuId=?
11:33:11,540 - DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement
11:33:11,587 - DEBUG org.hibernate.type.StringType - binding 'test1' to parameter: 1
11:33:11,587 - DEBUG org.hibernate.type.StringType - binding 'test1' to parameter: 1
11:33:11,587 - DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0)
11:33:11,587 - DEBUG org.hibernate.loader.Loader - processing result set
11:33:11,587 - DEBUG org.hibernate.loader.Loader - result set row: 0
11:33:11,587 - DEBUG org.hibernate.loader.Loader - result row: EntityKey[vo.sku.OwnSku#test1]
11:33:11,587 - DEBUG org.hibernate.loader.Loader - Initializing object from ResultSet: [vo.sku.OwnSku#test1]
11:33:11,602 - DEBUG org.hibernate.persister.entity.BasicEntityPersister - Hydrating entity: [vo.sku.OwnSku#test1]
11:33:11,602 - DEBUG org.hibernate.type.StringType - returning 'testing' as column: title1_0_
11:33:11,602 - DEBUG org.hibernate.type.StringType - returning 'testing' as column: title1_0_
11:33:11,602 - DEBUG org.hibernate.type.StringType - returning null as column: descript3_1_0_
11:33:11,602 - DEBUG org.hibernate.type.StringType - returning null as column: descript3_1_0_
11:33:11,602 - DEBUG org.hibernate.type.StringType - returning null as column: picUrl1_0_
11:33:11,602 - DEBUG org.hibernate.type.StringType - returning null as column: picUrl1_0_
11:33:11,602 - DEBUG org.hibernate.type.StringType - returning null as column: brand1_0_
11:33:11,602 - DEBUG org.hibernate.type.StringType - returning null as column: brand1_0_
11:33:11,602 - DEBUG org.hibernate.type.StringType - returning null as column: model1_0_
11:33:11,602 - DEBUG org.hibernate.type.StringType - returning null as column: model1_0_
11:33:11,602 - DEBUG org.hibernate.type.StringType - returning null as column: productT7_1_0_
11:33:11,602 - DEBUG org.hibernate.type.StringType - returning null as column: productT7_1_0_
11:33:11,602 - DEBUG org.hibernate.type.StringType - returning 'O' as column: supplyType1_0_
11:33:11,602 - DEBUG org.hibernate.type.StringType - returning 'O' as column: supplyType1_0_
11:33:11,602 - DEBUG org.hibernate.type.StringType - returning 'A' as column: status1_0_
11:33:11,602 - DEBUG org.hibernate.type.StringType - returning 'A' as column: status1_0_
11:33:11,602 - DEBUG org.hibernate.type.StringType - returning null as column: groupId1_0_
11:33:11,602 - DEBUG org.hibernate.type.StringType - returning null as column: groupId1_0_
11:33:11,602 - DEBUG org.hibernate.loader.Loader - done processing result set (1 rows)
11:33:11,602 - DEBUG org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1)
11:33:11,602 - DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
11:33:11,602 - DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement
11:33:11,602 - DEBUG org.hibernate.loader.Loader - total objects hydrated: 1
11:33:11,602 - DEBUG org.hibernate.engine.TwoPhaseLoad - resolving associations for [vo.sku.OwnSku#test1]
11:33:11,618 - DEBUG org.hibernate.engine.CollectionLoadContext - creating collection wrapper:[vo.sku.OwnSku.costs#test1]
11:33:11,618 - DEBUG org.hibernate.engine.TwoPhaseLoad - done materializing entity [vo.sku.OwnSku#test1]
11:33:11,618 - DEBUG org.hibernate.engine.PersistenceContext - initializing non-lazy collections
11:33:11,618 - DEBUG org.hibernate.loader.Loader - done entity load
11:33:11,618 - DEBUG org.hibernate.jdbc.JDBCContext - after autocommit
11:33:11,618 - DEBUG org.hibernate.impl.SessionImpl - after transaction completion
11:33:11,618 - DEBUG org.hibernate.engine.Cascades - processing cascade ACTION_MERGE for: vo.sku.OwnSku
11:33:11,634 - DEBUG org.hibernate.engine.Cascades - cascade ACTION_MERGE for collection: vo.sku.OwnSku.costs
11:33:11,634 - DEBUG org.hibernate.engine.Cascades - cascading to merge: vo.sku.SkuCost
11:33:11,634 - DEBUG org.hibernate.engine.Cascades - id unsaved-value strategy UNDEFINED
11:33:11,634 - DEBUG org.hibernate.event.def.AbstractSaveEventListener - detached instance of: vo.sku.SkuCost
11:33:11,634 - DEBUG org.hibernate.event.def.DefaultMergeEventListener - merging detached instance
11:33:11,634 - DEBUG org.hibernate.event.def.DefaultLoadEventListener - loading entity: [vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=2005-11-03 11:33:11, skuId=test1, status=A}]
11:33:11,634 - DEBUG org.hibernate.event.def.DefaultLoadEventListener - attempting to resolve: [vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=2005-11-03 11:33:11, skuId=test1, status=A}]
11:33:11,634 - DEBUG org.hibernate.event.def.DefaultLoadEventListener - object not resolved in any cache: [vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=2005-11-03 11:33:11, skuId=test1, status=A}]
11:33:11,634 - DEBUG org.hibernate.persister.entity.BasicEntityPersister - Materializing entity: [vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=2005-11-03 11:33:11, skuId=test1, status=A}]
11:33:11,634 - DEBUG org.hibernate.loader.Loader - loading entity: [vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=2005-11-03 11:33:11, skuId=test1, status=A}]
11:33:11,634 - DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
11:33:11,634 - DEBUG org.hibernate.SQL - select skucost0_.skuId as skuId0_, skucost0_.status as status0_, skucost0_.effectiveFrom as effectiv3_0_, skucost0_.cost as cost2_0_, skucost0_.postage as postage2_0_, skucost0_.effectiveTo as effectiv6_2_0_ from skucost skucost0_ where skucost0_.skuId=? and skucost0_.status=? and skucost0_.effectiveFrom=?
11:33:11,634 - DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement
11:33:11,634 - DEBUG org.hibernate.type.StringType - binding 'test1' to parameter: 1
11:33:11,634 - DEBUG org.hibernate.type.StringType - binding 'test1' to parameter: 1
11:33:11,634 - DEBUG org.hibernate.type.StringType - binding 'A' to parameter: 2
11:33:11,634 - DEBUG org.hibernate.type.StringType - binding 'A' to parameter: 2
11:33:11,634 - DEBUG org.hibernate.type.TimestampType - binding '2005-11-03 11:33:11' to parameter: 3
11:33:11,634 - DEBUG org.hibernate.type.TimestampType - binding '2005-11-03 11:33:11' to parameter: 3
11:33:11,649 - DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0)
11:33:11,649 - DEBUG org.hibernate.loader.Loader - processing result set
11:33:11,649 - DEBUG org.hibernate.loader.Loader - done processing result set (0 rows)
11:33:11,649 - DEBUG org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1)
11:33:11,649 - DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
11:33:11,649 - DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement
11:33:11,649 - DEBUG org.hibernate.loader.Loader - total objects hydrated: 0
11:33:11,649 - DEBUG org.hibernate.engine.PersistenceContext - initializing non-lazy collections
11:33:11,649 - DEBUG org.hibernate.loader.Loader - done entity load
11:33:11,649 - DEBUG org.hibernate.jdbc.JDBCContext - after autocommit
11:33:11,649 - DEBUG org.hibernate.impl.SessionImpl - after transaction completion
11:33:11,649 - DEBUG org.hibernate.event.def.DefaultMergeEventListener - merging transient instance
11:33:11,649 - DEBUG org.hibernate.event.def.AbstractSaveEventListener - generated identifier: component[skuId,status,effectiveFrom]{effectiveFrom=null, skuId=null, status=null}, using strategy: org.hibernate.id.Assigned
11:33:11,649 - DEBUG org.hibernate.event.def.AbstractSaveEventListener - saving [vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=null, skuId=null, status=null}]
11:33:11,649 - DEBUG org.hibernate.engine.Cascades - done cascade ACTION_MERGE for collection: vo.sku.OwnSku.costs
11:33:11,649 - DEBUG org.hibernate.engine.Cascades - done processing cascade ACTION_MERGE for: vo.sku.OwnSku
11:33:11,665 - DEBUG org.hibernate.event.def.DefaultInitializeCollectionEventListener - initializing collection [vo.sku.OwnSku.costs#test1]
11:33:11,665 - DEBUG org.hibernate.event.def.DefaultInitializeCollectionEventListener - checking second-level cache
11:33:11,681 - DEBUG org.hibernate.event.def.DefaultInitializeCollectionEventListener - collection not cached
11:33:11,681 - DEBUG org.hibernate.loader.Loader - loading collection: [vo.sku.OwnSku.costs#test1]
11:33:11,681 - DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
11:33:11,681 - DEBUG org.hibernate.SQL - select costs0_.skuId as skuId__, costs0_.status as status__, costs0_.effectiveFrom as effectiv3___, costs0_.skuId as skuId0_, costs0_.status as status0_, costs0_.effectiveFrom as effectiv3_0_, costs0_.cost as cost2_0_, costs0_.postage as postage2_0_, costs0_.effectiveTo as effectiv6_2_0_ from skucost costs0_ where costs0_.skuId=? order by costs0_.effectiveFrom desc
11:33:11,681 - DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement
11:33:11,681 - DEBUG org.hibernate.type.StringType - binding 'test1' to parameter: 1
11:33:11,681 - DEBUG org.hibernate.type.StringType - binding 'test1' to parameter: 1
11:33:11,696 - DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0)
11:33:11,696 - DEBUG org.hibernate.loader.Loader - result set contains (possibly empty) collection: [vo.sku.OwnSku.costs#test1]
11:33:11,696 - DEBUG org.hibernate.engine.CollectionLoadContext - uninitialized collection: initializing
11:33:11,696 - DEBUG org.hibernate.loader.Loader - processing result set
11:33:11,712 - DEBUG org.hibernate.loader.Loader - result set row: 0
11:33:11,712 - DEBUG org.hibernate.type.StringType - returning 'test1' as column: skuId0_
11:33:11,712 - DEBUG org.hibernate.type.StringType - returning 'test1' as column: skuId0_
11:33:11,712 - DEBUG org.hibernate.type.StringType - returning 'A' as column: status0_
11:33:11,712 - DEBUG org.hibernate.type.StringType - returning 'A' as column: status0_
11:33:11,712 - DEBUG org.hibernate.type.TimestampType - returning '2005-11-03 11:11:02' as column: effectiv3_0_
11:33:11,712 - DEBUG org.hibernate.type.TimestampType - returning '2005-11-03 11:11:02' as column: effectiv3_0_
11:33:11,712 - DEBUG org.hibernate.loader.Loader - result row: EntityKey[vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=2005-11-03 11:11:02, skuId=test1, status=A}]
11:33:11,712 - DEBUG org.hibernate.loader.Loader - Initializing object from ResultSet: [vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=2005-11-03 11:11:02, skuId=test1, status=A}]
11:33:11,712 - DEBUG org.hibernate.persister.entity.BasicEntityPersister - Hydrating entity: [vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=2005-11-03 11:11:02, skuId=test1, status=A}]
11:33:11,712 - DEBUG org.hibernate.type.DoubleType - returning '500.0' as column: cost2_0_
11:33:11,712 - DEBUG org.hibernate.type.DoubleType - returning '500.0' as column: cost2_0_
11:33:11,712 - DEBUG org.hibernate.type.DoubleType - returning '1.0' as column: postage2_0_
11:33:11,712 - DEBUG org.hibernate.type.DoubleType - returning '1.0' as column: postage2_0_
11:33:11,712 - DEBUG org.hibernate.type.TimestampType - returning null as column: effectiv6_2_0_
11:33:11,712 - DEBUG org.hibernate.type.TimestampType - returning null as column: effectiv6_2_0_
11:33:11,712 - DEBUG org.hibernate.type.StringType - returning 'test1' as column: skuId__
11:33:11,712 - DEBUG org.hibernate.type.StringType - returning 'test1' as column: skuId__
11:33:11,712 - DEBUG org.hibernate.loader.Loader - found row of collection: [vo.sku.OwnSku.costs#test1]
11:33:11,712 - DEBUG org.hibernate.engine.CollectionLoadContext - reading row
11:33:11,712 - DEBUG org.hibernate.type.StringType - returning 'test1' as column: skuId__
11:33:11,712 - DEBUG org.hibernate.type.StringType - returning 'test1' as column: skuId__
11:33:11,712 - DEBUG org.hibernate.type.StringType - returning 'A' as column: status__
11:33:11,712 - DEBUG org.hibernate.type.StringType - returning 'A' as column: status__
11:33:11,712 - DEBUG org.hibernate.type.TimestampType - returning '2005-11-03 11:11:02' as column: effectiv3___
11:33:11,712 - DEBUG org.hibernate.type.TimestampType - returning '2005-11-03 11:11:02' as column: effectiv3___
11:33:11,712 - DEBUG org.hibernate.event.def.DefaultLoadEventListener - loading entity: [vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=2005-11-03 11:11:02, skuId=test1, status=A}]
11:33:11,712 - DEBUG org.hibernate.event.def.DefaultLoadEventListener - attempting to resolve: [vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=2005-11-03 11:11:02, skuId=test1, status=A}]
11:33:11,712 - DEBUG org.hibernate.event.def.DefaultLoadEventListener - resolved object in session cache: [vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=2005-11-03 11:11:02, skuId=test1, status=A}]
11:33:11,727 - DEBUG org.hibernate.loader.Loader - result set row: 1
11:33:11,727 - DEBUG org.hibernate.type.StringType - returning 'test1' as column: skuId0_
11:33:11,727 - DEBUG org.hibernate.type.StringType - returning 'test1' as column: skuId0_
11:33:11,727 - DEBUG org.hibernate.type.StringType - returning 'A' as column: status0_
11:33:11,727 - DEBUG org.hibernate.type.StringType - returning 'A' as column: status0_
11:33:11,727 - DEBUG org.hibernate.type.TimestampType - returning '2005-11-03 11:10:40' as column: effectiv3_0_
11:33:11,727 - DEBUG org.hibernate.type.TimestampType - returning '2005-11-03 11:10:40' as column: effectiv3_0_
11:33:11,727 - DEBUG org.hibernate.loader.Loader - result row: EntityKey[vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=2005-11-03 11:10:40, skuId=test1, status=A}]
11:33:11,727 - DEBUG org.hibernate.loader.Loader - Initializing object from ResultSet: [vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=2005-11-03 11:10:40, skuId=test1, status=A}]
11:33:11,727 - DEBUG org.hibernate.persister.entity.BasicEntityPersister - Hydrating entity: [vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=2005-11-03 11:10:40, skuId=test1, status=A}]
11:33:11,727 - DEBUG org.hibernate.type.DoubleType - returning '50.0' as column: cost2_0_
11:33:11,727 - DEBUG org.hibernate.type.DoubleType - returning '50.0' as column: cost2_0_
11:33:11,727 - DEBUG org.hibernate.type.DoubleType - returning '1.0' as column: postage2_0_
11:33:11,727 - DEBUG org.hibernate.type.DoubleType - returning '1.0' as column: postage2_0_
11:33:11,727 - DEBUG org.hibernate.type.TimestampType - returning null as column: effectiv6_2_0_
11:33:11,727 - DEBUG org.hibernate.type.TimestampType - returning null as column: effectiv6_2_0_
11:33:11,727 - DEBUG org.hibernate.type.StringType - returning 'test1' as column: skuId__
11:33:11,727 - DEBUG org.hibernate.type.StringType - returning 'test1' as column: skuId__
11:33:11,727 - DEBUG org.hibernate.loader.Loader - found row of collection: [vo.sku.OwnSku.costs#test1]
11:33:11,727 - DEBUG org.hibernate.engine.CollectionLoadContext - reading row
11:33:11,727 - DEBUG org.hibernate.type.StringType - returning 'test1' as column: skuId__
11:33:11,727 - DEBUG org.hibernate.type.StringType - returning 'test1' as column: skuId__
11:33:11,727 - DEBUG org.hibernate.type.StringType - returning 'A' as column: status__
11:33:11,727 - DEBUG org.hibernate.type.StringType - returning 'A' as column: status__
11:33:11,727 - DEBUG org.hibernate.type.TimestampType - returning '2005-11-03 11:10:40' as column: effectiv3___
11:33:11,727 - DEBUG org.hibernate.type.TimestampType - returning '2005-11-03 11:10:40' as column: effectiv3___
11:33:11,727 - DEBUG org.hibernate.event.def.DefaultLoadEventListener - loading entity: [vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=2005-11-03 11:10:40, skuId=test1, status=A}]
11:33:11,727 - DEBUG org.hibernate.event.def.DefaultLoadEventListener - attempting to resolve: [vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=2005-11-03 11:10:40, skuId=test1, status=A}]
11:33:11,727 - DEBUG org.hibernate.event.def.DefaultLoadEventListener - resolved object in session cache: [vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=2005-11-03 11:10:40, skuId=test1, status=A}]
11:33:11,727 - DEBUG org.hibernate.loader.Loader - done processing result set (2 rows)
11:33:11,727 - DEBUG org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1)
11:33:11,727 - DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
11:33:11,727 - DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement
11:33:11,727 - DEBUG org.hibernate.loader.Loader - total objects hydrated: 2
11:33:11,727 - DEBUG org.hibernate.engine.TwoPhaseLoad - resolving associations for [vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=2005-11-03 11:11:02, skuId=test1, status=A}]
11:33:11,727 - DEBUG org.hibernate.engine.TwoPhaseLoad - done materializing entity [vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=2005-11-03 11:11:02, skuId=test1, status=A}]
11:33:11,727 - DEBUG org.hibernate.engine.TwoPhaseLoad - resolving associations for [vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=2005-11-03 11:10:40, skuId=test1, status=A}]
11:33:11,727 - DEBUG org.hibernate.engine.TwoPhaseLoad - done materializing entity [vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=2005-11-03 11:10:40, skuId=test1, status=A}]
11:33:11,727 - DEBUG org.hibernate.engine.CollectionLoadContext - 1 collections were found in result set
11:33:11,727 - DEBUG org.hibernate.engine.CollectionLoadContext - collection fully initialized: [vo.sku.OwnSku.costs#test1]
11:33:11,727 - DEBUG org.hibernate.engine.CollectionLoadContext - 1 collections initialized
11:33:11,727 - DEBUG org.hibernate.engine.PersistenceContext - initializing non-lazy collections
11:33:11,743 - DEBUG org.hibernate.loader.Loader - done loading collection
11:33:11,743 - DEBUG org.hibernate.event.def.DefaultInitializeCollectionEventListener - collection initialized
11:33:11,743 - DEBUG org.hibernate.event.def.AbstractFlushingEventListener - flushing session
11:33:11,743 - DEBUG org.hibernate.event.def.AbstractFlushingEventListener - processing flush-time cascades
11:33:11,743 - DEBUG org.hibernate.engine.Cascades - processing cascade ACTION_SAVE_UPDATE for: vo.sku.OwnSku
11:33:11,743 - DEBUG org.hibernate.engine.Cascades - cascade ACTION_SAVE_UPDATE for collection: vo.sku.OwnSku.costs
11:33:11,743 - DEBUG org.hibernate.engine.Cascades - cascading to saveOrUpdate: vo.sku.SkuCost
11:33:11,743 - DEBUG org.hibernate.event.def.AbstractSaveEventListener - persistent instance of: vo.sku.SkuCost
11:33:11,743 - DEBUG org.hibernate.event.def.DefaultSaveOrUpdateEventListener - ignoring persistent instance
11:33:11,743 - DEBUG org.hibernate.event.def.DefaultSaveOrUpdateEventListener - object already associated with session: [vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=null, skuId=null, status=null}]
11:33:11,743 - DEBUG org.hibernate.engine.Cascades - done cascade ACTION_SAVE_UPDATE for collection: vo.sku.OwnSku.costs
11:33:11,743 - DEBUG org.hibernate.engine.Cascades - deleting orphans for collection: vo.sku.OwnSku.costs
11:33:11,743 - DEBUG org.hibernate.engine.Cascades - deleting orphaned: vo.sku.SkuCost
11:33:11,743 - DEBUG org.hibernate.event.def.DefaultDeleteEventListener - deleting a persistent instance
11:33:11,743 - DEBUG org.hibernate.event.def.DefaultDeleteEventListener - deleting [vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=2005-11-03 11:10:40, skuId=test1, status=A}]
11:33:11,743 - DEBUG org.hibernate.impl.SessionImpl - setting cache mode to: GET
11:33:11,743 - DEBUG org.hibernate.impl.SessionImpl - setting cache mode to: NORMAL
11:33:11,743 - DEBUG org.hibernate.impl.SessionImpl - setting cache mode to: GET
11:33:11,743 - DEBUG org.hibernate.impl.SessionImpl - setting cache mode to: NORMAL
11:33:11,743 - DEBUG org.hibernate.engine.Cascades - deleting orphaned: vo.sku.SkuCost
11:33:11,743 - DEBUG org.hibernate.event.def.DefaultDeleteEventListener - deleting a persistent instance
11:33:11,743 - DEBUG org.hibernate.event.def.DefaultDeleteEventListener - deleting [vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=2005-11-03 11:11:02, skuId=test1, status=A}]
11:33:11,743 - DEBUG org.hibernate.impl.SessionImpl - setting cache mode to: GET
11:33:11,743 - DEBUG org.hibernate.impl.SessionImpl - setting cache mode to: NORMAL
11:33:11,743 - DEBUG org.hibernate.impl.SessionImpl - setting cache mode to: GET
11:33:11,743 - DEBUG org.hibernate.impl.SessionImpl - setting cache mode to: NORMAL
11:33:11,743 - DEBUG org.hibernate.engine.Cascades - done deleting orphans for collection: vo.sku.OwnSku.costs
11:33:11,743 - DEBUG org.hibernate.engine.Cascades - done processing cascade ACTION_SAVE_UPDATE for: vo.sku.OwnSku
11:33:11,743 - DEBUG org.hibernate.event.def.AbstractFlushingEventListener - dirty checking collections
11:33:11,743 - DEBUG org.hibernate.engine.CollectionEntry - Collection dirty: [vo.sku.OwnSku.costs#test1]
11:33:11,743 - DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushing entities and processing referenced collections
11:33:11,759 - DEBUG org.hibernate.engine.Collections - Collection found: [vo.sku.OwnSku.costs#test1], was: [vo.sku.OwnSku.costs#test1] (initialized)
11:33:11,759 - DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Processing unreferenced collections
11:33:11,759 - DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Scheduling collection removes/(re)creates/updates
11:33:11,759 - DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 1 insertions, 0 updates, 2 deletions to 4 objects
11:33:11,759 - DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 0 (re)creations, 1 updates, 0 removals to 1 collections
11:33:11,774 - DEBUG org.hibernate.pretty.Printer - listing entities:
11:33:11,774 - DEBUG org.hibernate.pretty.Printer - vo.sku.SkuCost{effectiveTo=null, cost=500.0, postage=1.0}
11:33:11,774 - DEBUG org.hibernate.pretty.Printer - vo.sku.SkuCost{effectiveTo=null, cost=50.0, postage=1.0}
11:33:11,774 - DEBUG org.hibernate.pretty.Printer - vo.sku.OwnSku{costs=[vo.sku.SkuCost], picUrl=null, groupId=null, productType=null, brand=null, title=testing, skuId=test1, description=null, supplyType=O, model=null, status=A}
11:33:11,774 - DEBUG org.hibernate.pretty.Printer - vo.sku.SkuCost{effectiveTo=null, cost=500.0, postage=1.0}
11:33:11,774 - DEBUG org.hibernate.event.def.AbstractFlushingEventListener - executing flush
11:33:11,790 - DEBUG org.hibernate.persister.entity.BasicEntityPersister - Inserting entity: [vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=null, skuId=null, status=null}]
11:33:11,790 - DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
11:33:11,790 - DEBUG org.hibernate.SQL - insert into skucost (cost, postage, effectiveTo, skuId, status, effectiveFrom) values (?, ?, ?, ?, ?, ?)
11:33:11,790 - DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement
11:33:11,790 - DEBUG org.hibernate.persister.entity.BasicEntityPersister - Dehydrating entity: [vo.sku.SkuCost#component[skuId,status,effectiveFrom]{effectiveFrom=null, skuId=null, status=null}]
11:33:11,790 - DEBUG org.hibernate.type.DoubleType - binding '500.0' to parameter: 1
11:33:11,790 - DEBUG org.hibernate.type.DoubleType - binding '500.0' to parameter: 1
11:33:11,790 - DEBUG org.hibernate.type.DoubleType - binding '1.0' to parameter: 2
11:33:11,790 - DEBUG org.hibernate.type.DoubleType - binding '1.0' to parameter: 2
11:33:11,790 - DEBUG org.hibernate.type.TimestampType - binding null to parameter: 3
11:33:11,790 - DEBUG org.hibernate.type.TimestampType - binding null to parameter: 3
11:33:11,790 - DEBUG org.hibernate.type.StringType - binding null to parameter: 4
11:33:11,790 - DEBUG org.hibernate.type.StringType - binding null to parameter: 4
11:33:11,790 - DEBUG org.hibernate.type.StringType - binding null to parameter: 5
11:33:11,790 - DEBUG org.hibernate.type.StringType - binding null to parameter: 5
11:33:11,790 - DEBUG org.hibernate.type.TimestampType - binding null to parameter: 6
11:33:11,790 - DEBUG org.hibernate.type.TimestampType - binding null to parameter: 6
11:33:11,790 - DEBUG org.hibernate.jdbc.AbstractBatcher - Adding to batch
11:33:11,790 - DEBUG org.hibernate.jdbc.AbstractBatcher - Executing batch size: 1
11:33:11,805 - DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
11:33:11,805 - DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement
11:33:11,805 - DEBUG org.hibernate.util.JDBCExceptionReporter - Could not execute JDBC batch update [insert into skucost (cost, postage, effectiveTo, skuId, status, effectiveFrom) values (?, ?, ?, ?, ?, ?)]
java.sql.BatchUpdateException: Column 'skuId' cannot be null
at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:822)
Is there anything wrong with the mapping or usage of merge?
Note: It seems the saveOrUpdate can solve the problem. But I'm really confused with the semantics of merge/saveOrUpdate.
|