Many thanks if who can help to find the reason, it has bothered me for a long time.
I am using hibernate to access mysql.
and using following hql:
select productItem from OrdersProductItem productItem where productItem.orders.id = 11
and an exception popped up:
not-null property references a null or transient value: com.tudou.tudouadsales.plantable.entity.OrdersProductItem.orders; nested exception is org.hibernate.PropertyValueException: not-null property references a null or transient value: com.tudou.tudouadsales.plantable.entity.OrdersProductItem.orders
the call stack is:
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:628) at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:378) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:338) at com.tudou.tudouadsales.component.dao.BaseDaoHibernate.findByQueryUniqueResult(BaseDaoHibernate.java:347) at com.tudou.tudouadsales.plantable.dao.impl.OrdersDaoHibernate.getOrdersListByRelatedOrdersId(OrdersDaoHibernate.java:243) at com.tudou.tudouadsales.plantable.service.impl.OrdersServiceImpl.CalculateOrders(OrdersServiceImpl.java:346) at com.tudou.tudouadsales.plantable.service.impl.OrdersServiceImpl.updateOrders(OrdersServiceImpl.java:467) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Here , the define of OrdersProductItem and orders is:
class Orders{ integer id; //not null ... ... }
in mysql: orders has the column: id
class OrdersProductItem { @ManyToOne(fetch = FetchType.LAZY) @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) @JoinColumn(name="orders_id",nullable=false) private Orders orders; }
in mysql: orders_product_item has the column: orders_id
So, what is wrong with the hql code???
thanks a lot!
}
|