-->
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: PropertyValueException - merge vs saveOrUpdate
PostPosted: Fri May 22, 2009 5:03 pm 
Beginner
Beginner

Joined: Wed Nov 12, 2008 12:07 pm
Posts: 21
Hello

I have 2 classes, Equipment and EquipmentType:

Code:
...
public class Equipment implements java.io.Serializable {
   @Id
   @GeneratedValue(strategy=GenerationType.SEQUENCE)
   @Column(name="oid", nullable=false, insertable=true, updatable=true, length=8)
   private Long oid;
   
   @ManyToOne(cascade={CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REFRESH},optional=false)
   @JoinColumn(name="Equ_oid", referencedColumnName="oid", nullable=false)
   private EquipmentType type;
...


EquipmentType is very simple and has no association with Equipment.

I'm getting this exception:
Quote:
Exception in thread "main" javax.ejb.EJBException: org.hibernate.PropertyValueException: not-null property references a null or transient value: xxx.commons.datamodel.model.Equipment.type
at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:63)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
...


Why does it happen? I know the NonUniqueObjectException issue with saveOrUpdate() but I don't know why does this happen. It works with merge().


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.