Results 1 to 2 of 2
  1. #1
    rockeymen is offline Member
    Join Date
    Aug 2011
    Posts
    1
    Rep Power
    0

    Default a strange BUG when using Hql : DataIntegrityViolationExcept

    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.OrdersProd uctItem.orders; nested exception is org.hibernate.PropertyValueException: not-null property references a null or transient value: com.tudou.tudouadsales.plantable.entity.OrdersProd uctItem.orders

    the call stack is:

    at org.springframework.orm.hibernate3.SessionFactoryU tils.convertHibernateAccessException(SessionFactor yUtils.java:628)
    at org.springframework.orm.hibernate3.HibernateAccess or.convertHibernateAccessException(HibernateAccess or.java:412)
    at org.springframework.orm.hibernate3.HibernateTempla te.execute(HibernateTemplate.java:378)
    at org.springframework.orm.hibernate3.HibernateTempla te.execute(HibernateTemplate.java:338)
    at com.tudou.tudouadsales.component.dao.BaseDaoHibern ate.findByQueryUniqueResult(BaseDaoHibernate.java: 347)
    at com.tudou.tudouadsales.plantable.dao.impl.OrdersDa oHibernate.getOrdersListByRelatedOrdersId(OrdersDa oHibernate.java:243)
    at com.tudou.tudouadsales.plantable.service.impl.Orde rsServiceImpl.CalculateOrders(OrdersServiceImpl.ja va:346)
    at com.tudou.tudouadsales.plantable.service.impl.Orde rsServiceImpl.updateOrders(OrdersServiceImpl.java: 467)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e 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!

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,184
    Rep Power
    19

Similar Threads

  1. Strange behaviour
    By imadabh in forum Threads and Synchronization
    Replies: 1
    Last Post: 05-11-2011, 03:31 PM
  2. Strange for loop
    By Grimmjow in forum New To Java
    Replies: 5
    Last Post: 01-23-2011, 10:52 PM
  3. strange outcome!
    By consurgens in forum New To Java
    Replies: 6
    Last Post: 08-20-2010, 09:36 AM
  4. strange swt exception
    By ahmed.kotb in forum SWT / JFace
    Replies: 0
    Last Post: 04-23-2009, 10:15 AM
  5. Strange problem
    By Tamir in forum Eclipse
    Replies: 1
    Last Post: 08-18-2008, 09:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •