Hibernate 3, MySQL 5.0, Spring 1.2.7
I have a problem creating this entity, when storing in the database, I get the exception: Exception: not-null property references a null or transient value.
This is the hbm
Code:
<class name="AccumulatedDailySales" table="accumulated_daily_sales" discriminator-value="null">
<cache usage="nonstrict-read-write"/>
<id name="id" column="id" type="long">
<generator class="native"/>
</id>
<discriminator column="type" type="char"/>
<version name="version" type="timestamp"/>
<property name="productType" type="productType" column="product_type"/>
<property name="posType" column="pos_type" type="posType"/>
<property name="countSale" column="count_sale" />
<property name="amountSale" column="amount_sale" />
<property name="dateSale" column="date_sale" type="date"/>
<many-to-one name="company" not-null="true" column="company"/>
<many-to-one name="product" not-null="true" column="product"/>
<many-to-one name="subWholeSaler" not-null="true" column="subWholeSaler"/>
<subclass name="ar.AccumulatedDailyClientSales" discriminator-value="C">
<many-to-one name="salesman" column="salesman_id" cascade="none" fetch="join"/>
<many-to-one name="client" column="client_id" cascade="none" fetch="join"/>
</subclass>
<subclass name="AccumulatedDailyResellerSales" discriminator-value="R">
<many-to-one name="reseller" column="reseller_id" cascade="none" fetch="join"/>
</subclass>
</class>
This is the statement that maps the table DAO
Code:
<bean id="accumDailySaleDao" class="AccumDailySaleDao">
<property name="sessionFactory" ref="sessionFactory"/>
<property name="referenceClassName" value="AccumulatedDailySales"/>
</bean>
This operation where I and store the object
Code:
for (SalesPerSubWholeSalerDTO sale: listProduct){
AccumulatedDailyClientSales accumulatedDailyClientSales = new AccumulatedDailyClientSales(dateAnalize,
sale.getWholesaler(), sale.getClient().getSalesman(), sale.getClient(), sale.getProduct().getCompany(), sale.getProduct(),sale.getProduct().getProductType(), sale.getPosType(), sale.getCount(), sale.getAmount());
this.accumDailySaleDao.save(accumulatedDailyClientSales);
}
and my test console
2011-02-11 12:15:12,968 INFO - Finalizó el calculo de acumulados diarios.
2011-02-11 12:15:19,093 DEBUG - save() [AccumulatedDailySales] - saving identity==[subWholeSalerC=1,companyC=3,productC=8,productType=VIRTUAL_CHARGE,posType=POSNET,amountSale=120,countSale=12,salesman=22,client=12]
2011-02-11 12:15:19,093 DEBUG - save() [AccumulatedDailySales] - object=[subWholeSalerC=1,companyC=3,productC=8,productType=VIRTUAL_CHARGE,posType=POSNET,amountSale=120,countSale=12,salesman=22,client=12]
testBulkCumulativeSales( - Exception: not-null property references a null or transient value: AccumulatedDailyClientSales.company; nested exception is org.hibernate.PropertyValueException: not-null property references a null or transient value: AccumulatedDailyClientSales.company
2011-02-11 12:15:19,156 ERROR - onTearDown error
org.springframework.transaction.UnexpectedRollbackException: Transaction has been rolled back because it has been marked as rollback-only
I think the problem is in defining the hbm, but can not find the cause. any clues?.