0 Replies Latest reply on Apr 14, 2006 2:58 PM by rnicob

    discriminator not set when persist a new class

    rnicob Newbie

      Hi,

      I have two classes, AA which inherits from A. I use two tables and a discriminator. The discriminator is null in the table when the class is persisted. Here is my code deployed on AS 4.0.4CR2

      ***********
      Class A
      ***********

      @Entity
      @Table(name = "A")
      @Inheritance(strategy = InheritanceType.JOINED)
      @DiscriminatorColumn(name = "DISCRIMINATOR", discriminatorType = DiscriminatorType.STRING, length = 5)
      @DiscriminatorValue("A")
      public class A implements Serializable {
      
       private short ida;
      
       public A() {
       }
      
       public A(short ida) {
       this.ida = ida;
       }
      
       @SequenceGenerator(name = "gen_a", sequenceName = "seq_a_id", allocationSize=1)
       @Id
       @GeneratedValue(strategy = SEQUENCE, generator = "gen_a")
       @Column(name="IDA")
       public short getIda() {
       return ida;
       }
       public void setIda(short ida) {
       this.ida = ida;
       }
      }



      ***********
      Class AA
      ***********

      @Entity
      @Table(name = "AA")
      @PrimaryKeyJoinColumn(name = "IDAA")
      @DiscriminatorValue("AA")
      public class AA extends A {
      
      }



      ***********
      TABLES
      ***********
      CREATE TABLE A (
       idA number(2) constraint a_pk primary key,
       discriminator varchar2(5) constraint a_c_discriminator check (discriminator in ('A','AA'))
      );
      
      create table AA(
       idAA number(2) constraint aa_pk primary key constraint aa_ref_a references a
      );


      ***********
      CLIENT
      ***********
      public void test(){
       ...
      
       AA a = new AA();
       adao.persist(a);
      
       ...
       }


      **********

      Thanks for your help

      Nicolas Roux