You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by rohitraghuwanshi <ro...@gmail.com> on 2013/06/08 01:27:16 UTC

XML ORM Mappings, where to define common Mapped Super Class?

Hello All,
    we have a common mapped super class which contains the common fields
(and id field) of many entities. The ORM of these entities have been defined
in their own xml mappings file.
Where and how should we declare the mapped super class? We tried defining it
in its own ORM mappings file but it doesn't seem to be getting read as
parent entity.
Should this be defined as an annotation based mapped super class? If so do
we need to include a 
*<mapped-superclass class="my.mappedsuperclass.classname"
</mapped-superclass>*
 in all the orm xml files?

Thanks



--
View this message in context: http://openjpa.208410.n2.nabble.com/XML-ORM-Mappings-where-to-define-common-Mapped-Super-Class-tp7584090.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: XML ORM Mappings, where to define common Mapped Super Class?

Posted by rohitraghuwanshi <ro...@gmail.com>.
Rick, Thanks for the reply.
Yes, we did add all the mapping files to persistence.xml (including the one
containing the mapped super class).

One of our application's requirement is to be able to query the physical
field name of an attribute of the entity. We find that we were not able to
get the meta for the mapped super class in JBoss without also adding in the
persistence.xml the following line.

*<class>a.b.c.OurMappedSuperclassName</class>*

Regards,
Rohit



--
View this message in context: http://openjpa.208410.n2.nabble.com/XML-ORM-Mappings-where-to-define-common-Mapped-Super-Class-tp7584090p7584143.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: XML ORM Mappings, where to define common Mapped Super Class?

Posted by Rick Curtis <cu...@gmail.com>.
I'm somewhat confused by your question(s), but I'll give it a shot.

> Where and how should we declare the mapped super class?
You need to declare your common parent class via :  [@MappedSuper class
annotation in the parent class, or via the <mapped-super-class> element a
mapping (orm.xml) file.]

> We tried defining it in its own ORM mappings file but it doesn't seem to
be getting read as parent entity.
If you had all of your mapping information in  one file (META-INF/orm.xml)
it should work, but It sounds like you have multiple mapping files. Did you
add a reference from your persistence.xml file to each mapping file via the
<mapping-file/> element? If not, that is most likely what is giving your
problems.

    <persistence-unit name="cache-mode-disable">
        <mapping-file>META-INF/caching-orm.xml</mapping-file> <!-- You need
one of these entries for each mapping file -->
        <shared-cache-mode>DISABLE_SELECTIVE</shared-cache-mode>
        <properties>

Hopefully this helps. Let us know how it goes.

Thanks,
Rick

On Fri, Jun 7, 2013 at 6:27 PM, rohitraghuwanshi <
rohit.raghuwanshi@gmail.com> wrote:

> Hello All,
>     we have a common mapped super class which contains the common fields
> (and id field) of many entities. The ORM of these entities have been
> defined
> in their own xml mappings file.
> Where and how should we declare the mapped super class? We tried defining
> it
> in its own ORM mappings file but it doesn't seem to be getting read as
> parent entity.
> Should this be defined as an annotation based mapped super class? If so do
> we need to include a
> *<mapped-superclass class="my.mappedsuperclass.classname"
> </mapped-superclass>*
>  in all the orm xml files?
>
> Thanks
>
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/XML-ORM-Mappings-where-to-define-common-Mapped-Super-Class-tp7584090.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>



-- 
*Rick Curtis*