[jboss-user] [JBoss Seam] - Fail to persist sub class
xtia004
do-not-reply at jboss.com
Mon Sep 11 23:43:52 EDT 2006
I have the following code. CreditCardPayment is inherited from Payment and added some extra fields.
@Entity
| @Table(name = "PAYMENT")
| @Name("payment")
| @Inheritance(strategy=InheritanceType.JOINED)
| @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)
| @Id
| @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;
|
| ...
| }
|
|
|
| @Entity
| @Table(name = "CREDITCARD_PAYMENT")
| @Name("creditCardPayment")
| @DiscriminatorValue("CC")
| public class CreditCardPayment extends Payment {
|
| private static final long serialVersionUID = -4171432845137278960L;
|
| @JoinColumn(name = "CREDITCARD_ID")
| @ManyToOne
| 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:anonymous wrote : 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();
| payment.setAuthCode(authCode);
| payment.setDpsTxnRef(dpsTxnRef);
| payment.setCreditCard(card);
| payment.setPaymentCode(paymentCode);
| payment.setPaidAmount(getSelectedSum());
| payment.setPaidDate(DateTimeUtil.getCurrentDate());
| payment.setPayMethod(payMethod);
| ...
| em.persist(payment);
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3970880#3970880
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3970880
More information about the jboss-user
mailing list