1 Reply Latest reply on Oct 31, 2012 10:48 AM by Adam Warski

    problem in Inheritance mapping

    Dhifi Borni Newbie


      I have a problem mapping for this design;


      I used  joined-subclass  for the first level  and  subclass  for the second level .

      for example I want to add a new invoice sales So the code is: I used a mapping  file for each class




         <class name="src.Document" table="DOCUMENT">

            <composite-id class="src.IdDocument" name="identifiant">

                <key-property column="NUM_DOC" name="numero" />

                <key-property column="TYPE_DOC" name="type" />



            <discriminator column="TYPE" type="string" />







            <joined-subclass name="src.DocumentSale" extends="src.Document" table="DOCUMENT_SALE">
                            <key property-ref="identifiant">
                  <column name="NUM_DOC"></column>
                  <column name="TYPE_DOC"></column>
            <property name="ref" column="REF"  type="java.lang.String"/>        



         <subclass name="src.InvoiceSale" extends="src.DocumentSale"             


      in code java

            InvoiceSale invoice = new InvoiceSale();
         Session session = service.getTheSession();
         session .saveOrUpdate(invoice );


      and this is what appears in the console

         Hibernate: insert into DOCUMENT (NUM_DOC, TYPE_DOC ,TYPE,HT, TTC) values (?, ?, ?, ?, ?)
         Hibernate: insert into DOCUMENT_SALE (NUM_DOC, TYPE_DOC ,REF) values (?, ?, ?)
         Hibernate: insert into DOCUMENT_SALE (NUM_DOC, TYPE_DOC ,) values (?, ?)
         SEVERE: ORA-00001: violation  single  constraint



      it insert twice in the table DOCUMENT_SALE.I do not understand where does the problem.

      thank you in advance.