Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
The parent object is persisted but I get an exception on the child object.
not-null property references a null or transient value
Any help would be greatly appreciated.
Scott
Hibernate version:2.14
Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.model.Order" table="poc_orders">
<id name="orderId" type="long" column="orderid" unsaved-value="0" >
<generator class="sequence">
<param name="sequence">uid_sequence</param>
</generator>
</id>
<property name="batchId" column="batchId" not-null="true"/>
<property name="progSolNumber" column="prog_sol_number" not-null="true"/>
<set name="orderedProducts" table="POC_ORDERED_PRODUCTS" lazy="false" cascade="all" inverse="true">
<key column="ORDERID" />
<one-to-many class="com.model.OrderedProduct" />
</set>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.model.OrderedProduct" table="poc_ordered_products">
<id name="id" type="long" column="recid" unsaved-value="0" >
<generator class="sequence">
<param name="sequence">uid_sequence</param>
</generator>
</id>
<many-to-one name="order" class="com.model.Order" column="orderid" not-null="true" />
<property name="productId" column="productId" not-null="true"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close(): I am using spring
Full stack trace of any exception that occurs:
Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@1e58cb8 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@1e57e8f [ acquireIncrement -> 3, autoCommitOnClose -> false, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, idleConnectionTestPeriod -> -1, initialPoolSize -> 3, maxIdleTime -> 0, maxPoolSize -> 15, maxStatements -> 0, minPoolSize -> 3, nestedDataSource -> propertyCycle -> 300, testConnectionOnCheckout -> false ] , factoryClassLocation -> null, numHelperThreads -> 3 ]
- Use scrollable result sets: true
- Use JDBC3 getGeneratedKeys(): false
- Optimize cache for minimal puts: false
- Query language substitutions: {}
- cache provider: net.sf.ehcache.hibernate.Provider
- instantiating and configuring caches
- building session factory
- no JNDI name configured
- Creating shared instance of singleton bean 'transactionManager'
- Using DataSource [com.mchange.v2.c3p0.ComboPooledDataSource@e183e9] from Hibernate SessionFactory for HibernateTransactionManager
- Creating shared instance of singleton bean 'productDAO'
- Creating shared instance of singleton bean 'workingDAO'
- Creating shared instance of singleton bean 'outcomeLogDAO'
- Creating shared instance of singleton bean 'outcomeProductDAO'
- Creating shared instance of singleton bean 'orderedProductDAO'
- Creating shared instance of singleton bean 'orderDAO'
- Creating shared instance of singleton bean 'productManager'
- Creating shared instance of singleton bean 'productManagerTarget'
- Creating shared instance of singleton bean 'outcomeLogManager'
- Creating shared instance of singleton bean 'outcomeLogManagerTarget'
- Creating shared instance of singleton bean 'decisionManager'
.E
Time: 0.911
There was 1 error:
1) testAdd(com.dao.OrderDAOTest)org.springframework.orm.hibernate.HibernateSystemException: not-null property references a null or transient value: com.model.OrderedProduct.order; nested exception is net.sf.hibernate.PropertyValueException: not-null property references a null or transient value: com.model.OrderedProduct.order
net.sf.hibernate.PropertyValueException: not-null property references a null or transient value: com.model.OrderedProduct.order
Name and version of the database you are using:Oracle 9i
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
public class Order extends BaseObject{
private String progSolNumber;
private long orderId;
private long batchId;
private Set orderedProducts;
public String getProgSolNumber() {
return progSolNumber;
}
public void setProgSolNumber(String progSolNumber) {
this.progSolNumber = progSolNumber;
}
public long getOrderId() {
return orderId;
}
protected void setOrderId(long orderId) {
this.orderId = orderId;
}
public long getBatchId() {
return batchId;
}
public void setBatchId(long batchId) {
this.batchId = batchId;
}
public Set getOrderedProducts() {
return orderedProducts;
}
public void setOrderedProducts(Set orderedProducts) {
this.orderedProducts = orderedProducts;
}
public class OrderedProduct extends BaseObject{
private long id;
private long orderId;
private long productId;
private Order order;
public long getId() {
return id;
}
protected void setId(long id) {
this.id = id;
}
public long getOrderId() {
return order.getOrderId();
}
public Order getOrder() {
return order;
}
public void setOrder(Order order) {
this.order = order;
}
public long getproductId() {
return productId;
}
public void setProductId(long productId) {
this.productId = productId;
}
}