1 Reply Latest reply on Sep 12, 2006 7:05 PM by Simon Tian

    Fail to persist sub class

    Simon Tian Newbie

      I have the following code. CreditCardPayment is inherited from Payment and added some extra fields.

      @Table(name = "PAYMENT")
      @DiscriminatorColumn(name="PAY_METHOD", discriminatorType=DiscriminatorType.STRING, length=2)
      public class Payment implements java.io.Serializable {
       private static final long serialVersionUID = 581797746676908701L;
       @TableGenerator(name = "objectIdGen", table = "OP_SEQUENCE_GENERATOR", pkColumnName = "GEN_KEY", valueColumnName = "GEN_VALUE", pkColumnValue = "OBJECT_ID", initialValue = 1, allocationSize = 1)
       @GeneratedValue(strategy = GenerationType.TABLE, generator = "objectIdGen")
       @Column(name = "OBJECT_ID", nullable = false)
       private Long objID;
       @Column(name = "PAYMENT_CODE", length = 10, nullable = false)
       private String paymentCode;
       @Column(name = "PAID_AMOUNT", nullable = false)
       private BigDecimal paidAmount;
       @Column(name = "PAID_DATE", nullable = false)
       @Basic @Temporal(TemporalType.DATE)
       private Date paidDate;
       @Column(name = "PAY_METHOD", length = 2, nullable = false)
       private String payMethod;
      @Table(name = "CREDITCARD_PAYMENT")
      public class CreditCardPayment extends Payment {
       private static final long serialVersionUID = -4171432845137278960L;
       @JoinColumn(name = "CREDITCARD_ID")
       private CreditCard creditCard;
       @Column(name = "AUTH_CODE", length = 15, nullable = false)
       private String authCode;
       @Column(name = "DPS_TXN_REF", length = 31, nullable = false)
       private String dpsTxnRef;

      When I create object of CreditCardPayment using following code and persist it. I got exception:
      Caused by: org.hibernate.PropertyValueException: not-null property references a null or transient value: com.oneplace.payment.CreditCardPayment._paymentsBackref

      I have checked I didn't miss any fields. What's the property "paymentsBackref" from and how to set it. Please somebody help me.

      CreditCardPayment payment = new CreditCardPayment();