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;
}