-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: a strange BUG when using Hql : DataIntegrityViolationExcept
PostPosted: Thu Aug 25, 2011 7:13 am 
Newbie

Joined: Thu Aug 25, 2011 7:00 am
Posts: 1
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!



}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.