-->
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: Not-null property references a null or transient value
PostPosted: Wed Aug 27, 2008 7:45 am 
Newbie

Joined: Tue Oct 02, 2007 3:49 am
Posts: 17
Dear All,
I have a simple many to one unidirectional relationship table. In table 1 (trade_record), it will reference 2 tables. One is Company and another one is "IndexRoute". When I insert a new trade record. Either company or indexroute also generate a not-null property error. I had checked that both of company and indexRoute pointed to existing record. Thus, it won't be assigned null in the new trade record. Please kindly help.
Best Rdgs
Ellis

Quote:
org.hibernate.PropertyValueException: not-null property references a null or transient value: com.transfielder.ffa.trade.model.FFATradeRecord.broker
not-null property references a null or transient value: com.transfielder.ffa.trade.model.FFATradeRecord.broker



Code:
@Entity
@Table(name = "trade_record")
public class TradeRecord extends ModelBase implements Serializable {
   @Id
   @Column(name = "id", nullable = false)
   @GeneratedValue(strategy = GenerationType.AUTO)
   private Long id;

   @Temporal(TemporalType.DATE)
   @Column(name = "trade_date", nullable = false)
   private Date tradeDate = new Date();

   @ManyToOne(optional = false)
   @JoinColumn(name = "company_id")
   private Company broker;

   @ManyToOne(optional = false)
   @JoinColumn(name = "index_route_code")
   private IndexRoute indexRoute;
.....                 




Code:
import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "index_route")
public class IndexRoute implements Serializable {
   @Id
   @Column(name = "index_code", length = 10, unique = true)
   private String indexCode;

   public String getIndexCode() {
      return indexCode;
   }

   public void setIndexCode(String indexCode) {
      this.indexCode = indexCode;
   }


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.