-->
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.  [ 2 posts ] 
Author Message
 Post subject: Discriminator column is ignored in JOINED inheritance mappin
PostPosted: Tue Oct 20, 2009 3:02 pm 
Beginner
Beginner

Joined: Tue Dec 27, 2005 1:13 pm
Posts: 25
Location: Kingston, ON, Canada
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();
   }
}


Top
 Profile  
 
 Post subject: Re: Discriminator column is ignored in JOINED inheritance mappin
PostPosted: Sat Nov 21, 2009 4:17 pm 
Beginner
Beginner

Joined: Wed Nov 05, 2003 7:51 am
Posts: 22
I have the same problem with several of my inheritance object trees.

It seems that when the InheritanceType is JOINED, Hibernate doesn't actually need the discriminator value because it OUTER JOINS all of the subclass tables (horrible solution IMHO) and decides the object class by the result of the outer joins.

So it simply doesn't fill out the discriminator or fills it out with the root class.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

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.