Hi, I met a problem in JPA mapping. I have the following mapping classes. When I try to insert a record of T5Slip, the discriminator column TAX_SLIP_TYPE is always NULL. If I generate DDL with Hibernate Tools, the Discriminator column is ignored.
Anybody can help me?
Code:
@Entity
@Table(name = "TAX_SLIP")
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorColumn(name = "TAX_SLIP_TYPE", discriminatorType = DiscriminatorType.STRING, length=20)
@DiscriminatorValue("BaseTaxSlip")
public abstract class TaxSlip implements java.io.Serializable {
private static final long serialVersionUID = 5010251140815286270L;
@Id
@GeneratedValue
@Column(name = "TAX_SLIP_ID", unique = true, nullable = false)
private long taxSlipId;
... ...
Code:
@Entity
@Table(name = "T5_SLIP")
@DiscriminatorValue("T5Slip")
@PrimaryKeyJoinColumn(name="TAX_SLIP_ID",referencedColumnName="TAX_SLIP_ID")
public class T5Slip extends TaxSlip {
private static final long serialVersionUID = 1604464549045146997L;
@Column(name="RCP2_LST_NAME")
private String rcp2LastName;
... ...
Code:
@Test
public class TaxSlipHomeTest extends SeamTest {
public void createNewT5TaxSlip() throws Exception {
new ComponentTest() {
@Override
protected void testComponents() throws Exception {
System.out.println("test");
setValue("#{t5SlipHome.taxSlipId}", null);
invokeMethod("#{t5SlipHome.wire()}");
setValue("#{t5SlipHome.instance.clientNum}", "client#1");
setValue("#{t5SlipHome.instance.createTime}", new Timestamp(Calendar.getInstance().getTime().getTime()));
setValue("#{t5SlipHome.instance.rcp2FirstName}", "FisrtName2");
setValue("#{t5SlipHome.instance.rcp2LastName}", "LastName2");
setValue("#{t5SlipHome.instance.recipientFistName}", "FirstName1");
setValue("#{t5SlipHome.instance.recipientInitial}", "Initial1");
setValue("#{t5SlipHome.instance.recipientLastName}", "LastName1");
setValue("#{t5SlipHome.instance.recipientSIN}", "SIN");
setValue("#{t5SlipHome.instance.revenueQuebecInd}", false);
setValue("#{t5SlipHome.instance.status}", "P");
setValue("#{t5SlipHome.instance.taxYear}", 2008);
invokeMethod("#{t5SlipHome.persist()}");
System.out.println(getValue("#{t5SlipHome.instance.taxSlipId}"));
}
}.run();
}
}