-->
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.  [ 3 posts ] 
Author Message
 Post subject: Map a class that extends and implements
PostPosted: Thu Nov 25, 2004 8:54 pm 
Beginner
Beginner

Joined: Sun Feb 08, 2004 4:09 pm
Posts: 46
Hibernate version:
2.1.6

Name and version of the database you are using:
MySQL 4

Hi,

How to map a class that extends and implements?

Like:

A extends B
A implements C

I tried everything, and all I got was an empty table C... I can query objects that implements C (A), but any other class that references C gets an empty collection (since table C is always empty)

Would really appreciate an example...


Thanks in advance!!
Thiago Souza


Top
 Profile  
 
 Post subject: Re: Map a class that extends and implements
PostPosted: Fri Nov 26, 2004 2:12 am 
Senior
Senior

Joined: Sat Jul 17, 2004 5:16 pm
Posts: 143
Can you post your best guess at what you are trying to do, what you originally posted is not really clear as to what you want. I have mapped classes that extend some class and implement interfaces... I assume you know that if you map A, then no B's or C's will be mapped since they are above A in the class hierarchy... anyways, post your try...

Regards,
Chris


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 26, 2004 10:52 am 
Beginner
Beginner

Joined: Sun Feb 08, 2004 4:09 pm
Posts: 46
Hi!!

Well, the hierarchy is a little bit long, but for this post, here's what matters:

class PrestadorPessoaFisica extends PessoaFisica
Code:
        <subclass
            name="empresajunior.business.domain.PessoaFisica"
            dynamic-update="true"
            dynamic-insert="true"
            discriminator-value="PF"
        >
        <property
            name="CPF"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="str_cpf"
            length="12"
        />

        <property
            name="dataNascimento"
            type="java.sql.Date"
            update="true"
            insert="true"
            access="property"
            column="date_nascimento"
        />

        <component
            name="RG"
            class="empresajunior.business.domain.RG"
        >
        <property
            name="numero"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="str_rg_numero"
            length="11"
        />

        <property
            name="orgaoEmissor"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="str_orgao_emissor"
            length="15"
        />

        </component>

       <!--
               To add non XDoclet property mappings, create a file named
                hibernate-properties-PessoaFisica.xml
      containing the additional properties and place it in your merge dir.
       -->
        <subclass
            name="empresajunior.business.domain.PrestadorPessoaFisica"
            dynamic-update="true"
            dynamic-insert="true"
            discriminator-value="PF"
        >

        <set
            name="habilitacao"
            lazy="false"
            inverse="false"
            cascade="all-delete-orphan"
            sort="unsorted"
        >

              <key
                  column="oid_pessoa"
              >
              </key>

              <one-to-many
                  class="empresajunior.business.domain.Habilitacao"
              />

        </set>

        <set
            name="tipoVinculo"
            table="VINCULACAO"
            lazy="false"
            inverse="false"
            cascade="none"
            sort="unsorted"
        >

              <key
                  column="oid_pessoa"
              >
              </key>

              <many-to-many
                  class="empresajunior.business.domain.TipoVinculo"
                  column="oid_tipo_vinculo"
                  outer-join="auto"
               />

        </set>


class Prestador
Code:
    <class
        name="empresajunior.business.domain.Prestador"
        table="PRESTADOR"
        dynamic-update="false"
        dynamic-insert="false"
        select-before-update="false"
        optimistic-lock="version"
    >

        <id
            name="oid"
            column="oid_pessoa"
            type="java.lang.String"
            length="32"
        >
            <generator class="uuid.hex">
              <!-- 
                  To add non XDoclet generator parameters, create a file named
                  hibernate-generator-params-Prestador.xml
                  containing the additional parameters and place it in your merge dir.
              -->
            </generator>
        </id>

        <discriminator
            column="subclass"
            length="2"
        />

        <set
            name="habilitacao"
            lazy="false"
            inverse="false"
            cascade="all-delete-orphan"
            sort="unsorted"
        >

              <key
                  column="oid_pessoa"
              >
              </key>

              <one-to-many
                  class="empresajunior.business.domain.Habilitacao"
              />

        </set>

        <set
            name="tipoVinculo"
            table="VINCULACAO"
            lazy="false"
            inverse="false"
            cascade="none"
            sort="unsorted"
        >

              <key
                  column="oid_pessoa"
              >
              </key>

              <many-to-many
                  class="empresajunior.business.domain.TipoVinculo"
                  column="oid_tipo_vinculo"
                  outer-join="auto"
               />

        </set>

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-Prestador.xml
            containing the additional properties and place it in your merge dir.
        -->

    </class>




So here's what I don't get, I see PrestadorPessoaFisica being a subclass of PessoaFisica in the mappings, but i don't know where should I tell hibernate that PrestadorPessoaFisica implements Prestador

Thanks in advance,
Thiago Souza[/code]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.