-->
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: Question about deleting and PropertyValueException
PostPosted: Wed Apr 27, 2005 1:19 pm 
Newbie

Joined: Mon Apr 11, 2005 4:55 am
Posts: 16
Hello,

I have two questions about using hibernate.

I have a PropertyValueException when I use the session.delete() method. Here is the log trace :

org.hibernate.PropertyValueException: not-null property references a null or transient value: com.netqi.business.beans.misc.Origin.name

In fact, it is true that the name property of the Origin bean is null (and with a not null constraint in the database).

I resolve this problem by adding a new line just before the delete, witch load a bean proxy :
Code:
   public void delete(BusinessBean bean) throws DAOException {
      try {
         //new line added here
         bean = (BusinessBean)session.load(encapsulatedClass, bean.getId());
         session.delete(bean);
      } catch (HibernateException e) {
         logger.fatal("Problem while deleting a bean",e);
        throw new DAOException(e);
      }
   }


So, my questions are :
1 - why I just can't delete a row with only the id of the bean ?
2 - May this new line of code be problematic in another context, because it is a generic method ?

Thanks for your light


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.