You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Lars Vogel <la...@googlemail.com> on 2008/03/27 14:38:45 UTC

Mapping of table in persistence.xml

Hi,

Can you please sent me an example in which the mapping to a certain table is
done in persistence.xml?

I use orm.xml to map the class to a certain table:

<entity class="datamodel.Person">
      <table name="MYAPPLICATION.PEOPLETABLE"/>
        <attributes>
            <id name="id" />
            <basic name="firstName" />
            <basic name="lastName" />
            <transient name="nonsenseField" />
        </attributes>
    </entity>

I read that I have to do the same mapping in persistence.xml in the class
but I failed to find an example to get the right tag.

<class>datamodel.Person</class>

If I run this without this setting I receive the message:

Could not locate metadata for the class using alias "
MYAPPLICATION.PEOPLETABLE".

Best regards, Lars

Re: Mapping of table in persistence.xml

Posted by Lars Vogel <la...@googlemail.com>.
Hi Kevin,

It did not work. I have posted a new question to this email group. Best
regards, Lars

2008/3/29, Lars Vogel <la...@googlemail.com>:
>
> Hi Kevin,
>
> yes that was my question. Thank you, Lars
>
> 2008/3/28, Kevin Sutter <kw...@gmail.com>:
> >
> > Lars,
> > Table and field mapping via xml is not done in the persitence.xml.  It
> > is
> > only done as part of an orm.xml file.  Any defined orm.xml files that
> > you
> > wish to use need to be specified in your persistence.xml using the
> > <mapping-file> element.  But, the actual mapping is done in your
> > orm.xmlfile.
> >
> > So, if you have a file named orm.xml, your persistence.xml would have
> > something like this:
> >
> > <persistence-unit name="mypu">
> >     :
> >     <mapping-file>META-INF/orm.xml</mapping-file>
> >     :
> > </persistence-unit>
> >
> > Is this what you were asking about?
> >
> > Thanks,
> > Kevin
> >
> > On Fri, Mar 28, 2008 at 5:11 AM, Lars Vogel <la...@googlemail.com>
> > wrote:
> >
> >
> > > Any advice?
> > >
> > > 2008/3/27, Lars Vogel <la...@googlemail.com>:
> > > >
> > > > Hi,
> > > >
> > > > Can you please sent me an example in which the mapping to a certain
> > > table
> > > > is done in persistence.xml?
> > > >
> > > > I use orm.xml to map the class to a certain table:
> > > >
> > > > <entity class="datamodel.Person">
> > > >       <table name="MYAPPLICATION.PEOPLETABLE"/>
> > > >         <attributes>
> > > >             <id name="id" />
> > > >             <basic name="firstName" />
> > > >             <basic name="lastName" />
> > > >             <transient name="nonsenseField" />
> > > >         </attributes>
> > > >     </entity>
> > > >
> > > > I read that I have to do the same mapping in persistence.xml in the
> > > class
> > > > but I failed to find an example to get the right tag.
> > > >
> > > > <class>datamodel.Person</class>
> > > >
> > > > If I run this without this setting I receive the message:
> > > >
> > > > Could not locate metadata for the class using alias "
> > > > MYAPPLICATION.PEOPLETABLE".
> > > >
> > > > Best regards, Lars
> > > >
> > >
> >
>
>

Re: Mapping of table in persistence.xml

Posted by Lars Vogel <la...@googlemail.com>.
Hi Kevin,

yes that was my question. Thank you, Lars

2008/3/28, Kevin Sutter <kw...@gmail.com>:
>
> Lars,
> Table and field mapping via xml is not done in the persitence.xml.  It is
> only done as part of an orm.xml file.  Any defined orm.xml files that you
> wish to use need to be specified in your persistence.xml using the
> <mapping-file> element.  But, the actual mapping is done in your
> orm.xmlfile.
>
> So, if you have a file named orm.xml, your persistence.xml would have
> something like this:
>
> <persistence-unit name="mypu">
>     :
>     <mapping-file>META-INF/orm.xml</mapping-file>
>     :
> </persistence-unit>
>
> Is this what you were asking about?
>
> Thanks,
> Kevin
>
> On Fri, Mar 28, 2008 at 5:11 AM, Lars Vogel <la...@googlemail.com>
> wrote:
>
>
> > Any advice?
> >
> > 2008/3/27, Lars Vogel <la...@googlemail.com>:
> > >
> > > Hi,
> > >
> > > Can you please sent me an example in which the mapping to a certain
> > table
> > > is done in persistence.xml?
> > >
> > > I use orm.xml to map the class to a certain table:
> > >
> > > <entity class="datamodel.Person">
> > >       <table name="MYAPPLICATION.PEOPLETABLE"/>
> > >         <attributes>
> > >             <id name="id" />
> > >             <basic name="firstName" />
> > >             <basic name="lastName" />
> > >             <transient name="nonsenseField" />
> > >         </attributes>
> > >     </entity>
> > >
> > > I read that I have to do the same mapping in persistence.xml in the
> > class
> > > but I failed to find an example to get the right tag.
> > >
> > > <class>datamodel.Person</class>
> > >
> > > If I run this without this setting I receive the message:
> > >
> > > Could not locate metadata for the class using alias "
> > > MYAPPLICATION.PEOPLETABLE".
> > >
> > > Best regards, Lars
> > >
> >
>

Re: Mapping of table in persistence.xml

Posted by Kevin Sutter <kw...@gmail.com>.
Lars,
Table and field mapping via xml is not done in the persitence.xml.  It is
only done as part of an orm.xml file.  Any defined orm.xml files that you
wish to use need to be specified in your persistence.xml using the
<mapping-file> element.  But, the actual mapping is done in your orm.xmlfile.

So, if you have a file named orm.xml, your persistence.xml would have
something like this:

<persistence-unit name="mypu">
    :
    <mapping-file>META-INF/orm.xml</mapping-file>
    :
</persistence-unit>

Is this what you were asking about?

Thanks,
Kevin

On Fri, Mar 28, 2008 at 5:11 AM, Lars Vogel <la...@googlemail.com>
wrote:

> Any advice?
>
> 2008/3/27, Lars Vogel <la...@googlemail.com>:
> >
> > Hi,
> >
> > Can you please sent me an example in which the mapping to a certain
> table
> > is done in persistence.xml?
> >
> > I use orm.xml to map the class to a certain table:
> >
> > <entity class="datamodel.Person">
> >       <table name="MYAPPLICATION.PEOPLETABLE"/>
> >         <attributes>
> >             <id name="id" />
> >             <basic name="firstName" />
> >             <basic name="lastName" />
> >             <transient name="nonsenseField" />
> >         </attributes>
> >     </entity>
> >
> > I read that I have to do the same mapping in persistence.xml in the
> class
> > but I failed to find an example to get the right tag.
> >
> > <class>datamodel.Person</class>
> >
> > If I run this without this setting I receive the message:
> >
> > Could not locate metadata for the class using alias "
> > MYAPPLICATION.PEOPLETABLE".
> >
> > Best regards, Lars
> >
>

Re: Mapping of table in persistence.xml

Posted by Lars Vogel <la...@googlemail.com>.
Any advice?

2008/3/27, Lars Vogel <la...@googlemail.com>:
>
> Hi,
>
> Can you please sent me an example in which the mapping to a certain table
> is done in persistence.xml?
>
> I use orm.xml to map the class to a certain table:
>
> <entity class="datamodel.Person">
>       <table name="MYAPPLICATION.PEOPLETABLE"/>
>         <attributes>
>             <id name="id" />
>             <basic name="firstName" />
>             <basic name="lastName" />
>             <transient name="nonsenseField" />
>         </attributes>
>     </entity>
>
> I read that I have to do the same mapping in persistence.xml in the class
> but I failed to find an example to get the right tag.
>
> <class>datamodel.Person</class>
>
> If I run this without this setting I receive the message:
>
> Could not locate metadata for the class using alias "
> MYAPPLICATION.PEOPLETABLE".
>
> Best regards, Lars
>