You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Adam Hardy <ad...@cyberspaceroad.com> on 2007/10/29 13:40:26 UTC

initializing EMF with lists of mapping files

Hi List,

I am running JPA with a set of mapping files, one for each table in the database 
  plus a few for queries, and in my test environment I have additional mapping 
files that aren't required in container and in fact I would like to exclude.

So I made a second test persistence.xml and now I find though that I have to 
maintain 2 lists of mapping files.

I would like to initialize the entity manager factory programmatically to add 
the main list of mapping files, and then in testing, to add the extra mapping 
files as well.

There seems to be no method on the API where I do that programmatically though. 
Is that correct or have I overlooked something?


Regards
Adam

Re: initializing EMF with lists of mapping files

Posted by Adam Hardy <ad...@cyberspaceroad.com>.
OK, I hadn't thought of an XML technique for this.

Regarding the EntityManagerFactory.createEntityManager(String puName, Map props) 
call, are you saying that I can pass in the mapping file names as map entries 
with the key 'mapping'?

I hadn't thought of trying that even since the <mapping> node in persistence.xml 
is not a child of the <properties> node.

Regards
Adam

Patrick Linskey on 29/10/07 17:14, wrote:
> Hi,
> 
> You can do this with the
> EntityManagerFactory.createEntityManager(String puName, Map props)
> signature.
> 
> Alternately, you can use XML entities to define the shared mappings
> outside of your persistence units and refer to them in multiple
> places.
> 
> -Patrick
> 
> On 10/29/07, Adam Hardy <ad...@cyberspaceroad.com> wrote:
>> Hi List,
>>
>> I am running JPA with a set of mapping files, one for each table in the database
>>   plus a few for queries, and in my test environment I have additional mapping
>> files that aren't required in container and in fact I would like to exclude.
>>
>> So I made a second test persistence.xml and now I find though that I have to
>> maintain 2 lists of mapping files.
>>
>> I would like to initialize the entity manager factory programmatically to add
>> the main list of mapping files, and then in testing, to add the extra mapping
>> files as well.
>>
>> There seems to be no method on the API where I do that programmatically though.
>> Is that correct or have I overlooked something?
>>
>>
>> Regards
>> Adam
>>
> 
> 


Re: initializing EMF with lists of mapping files

Posted by Patrick Linskey <pl...@gmail.com>.
I would expect it to work with any (validating) XML parser. XSDs are
internal to the XML language; entities are external insofar as they're
SGML markup that the XML parser obeys.

That said, I could be totally wrong; maybe XSD-validating parsers
ignore DTD and entity content.

Ignoring your editor, what happens if you put an <!ENTITY declaration
after the <?xml bit but before the <persistence bit?

-Patrick

On Jan 2, 2008 9:10 AM, Adam Hardy <ad...@cyberspaceroad.org> wrote:
> Is that for use with DTDs only? It's not recognised by my XML editor where my
> persistence.xml starts:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
>
>
>
> Patrick Linskey on 30/12/07 19:16, wrote:
> > Hi,
> >
> > Probably the best way to do that is with XML entities:
> >
> > <!ENTITY commonmappings SYSTEM "commonmappings.xml"> <persistence-units>
> > <persistence-unit name="pu1"> &commonmappings;
> > <mapping-file>pu1-mappings.xml</mapping-file> </persistence-unit>
> > <persistence-unit name="pu2"> &commonmappings;
> > <mapping-file>pu2-mappings.xml</mapping-file> </persistence-unit>
> > </persistence-units>
> >
> > -Patrick
> >
> > On Dec 19, 2007 12:32 AM, Adam Hardy <ad...@cyberspaceroad.org> wrote:
> >> I omitted to mention that the pseudo-XML I gave doesn't work and I'm not
> >> clear how I can get it to include the other file.
> >>
> >>
> >> Adam Hardy on 18/12/07 21:55, wrote:
> >>> I have 2 persistence units, which share many of their mapping files, so
> >>> it is more like this:
> >>>
> >>> <persistence-unit name="mypu"> <mapping-file>mypu.xml</mapping-file>
> >>> <mapping-file>orm1.xml</mapping-file>
> >>> <mapping-file>orm2.xml</mapping-file> </persistence-unit>
> >>> <persistence-unit name="other"> <mapping-file>other.xml</mapping-file>
> >>> <mapping-file>orm1.xml</mapping-file>
> >>> <mapping-file>orm2.xml</mapping-file> </persistence-unit>
> >>>
> >>> and I want to cut out the duplication of the shared mapping files by
> >>> including just 1 seperate xml snippet like this:
> >>>
> >>> <persistence-unit name="mypu"> <mapping-file>mypu.xml</mapping-file>
> >>> <xi:include href="shared-mapping.xml"/> </persistence-unit>
> >>> <persistence-unit name="other"> <mapping-file>other.xml</mapping-file>
> >>> <xi:include href="shared-mapping.xml"/> </persistence-unit>
> >>>
> >>>
> >>> Michael Dick on 18/12/07 18:26, wrote:
> >>>> Hi Adam,
> >>>>
> >>>> Something like this should work  : <persistence-unit name="mypu">
> >>>> <mapping-file>orm1.xml</mapping-file>
> >>>> <mapping-file>orm2.xml</mapping-file> . . . </persistence-unit>
> >>>>
> >>>> Is this what you're looking for?
> >>>>
> >>>> -Mike
> >>>>
> >>>> On Dec 18, 2007 5:59 AM, Adam Hardy <ad...@cyberspaceroad.org>
> >>>> wrote:
> >>>>
> >>>>> I'm getting nowhere trying to massage my persistence.xml into
> >>>>> something that validates and at this point I'm getting spurious
> >>>>> errors from Eclipse about the well-formedness of the XML, so I'll ask
> >>>>> here to see if anyone's got an example to hand.
> >>>>>
> >>>>> I would like to include a list of mapping files in multiple places in
> >>>>> my persistence.xml (once in each persistence unit). I tried several
> >>>>> different ideas from the web, but I haven't got anything to validate
> >>>>> in my XML editor yet.
> >>>>>
> >>>>> i.e. I have a list like this:
> >>>>>
> >>>>>
> >>>>> <mapping-file>org/permacode/patternrepo/orm/Category.xml</mapping-file>
> >>>>>
> >>>>>
> >>>>> <mapping-file>org/permacode/patternrepo/orm/Market.xml</mapping-file>
> >>>>>  <mapping-file>org/permacode/patternrepo/orm/Code.xml</mapping-file>
> >>>>>
> >>>>> <mapping-file>org/permacode/patternrepo/orm/TestResult.xml</mapping-file>
> >>>>>
> >>>>>
> >>>>>
> >>>>> <mapping-file>org/permacode/patternrepo/orm/TradingParam.xml</mapping-file>
> >>>>>
> >>>>>
> >>>>>
> >>>>> which I want to include - I'd be really grateful if someone could
> >>>>> tell me the xml syntax for the include?
> >
>
>



-- 
Patrick Linskey
202 669 5907

Re: initializing EMF with lists of mapping files

Posted by Adam Hardy <ad...@cyberspaceroad.org>.
Is that for use with DTDs only? It's not recognised by my XML editor where my 
persistence.xml starts:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">


Patrick Linskey on 30/12/07 19:16, wrote:
> Hi,
> 
> Probably the best way to do that is with XML entities:
> 
> <!ENTITY commonmappings SYSTEM "commonmappings.xml"> <persistence-units> 
> <persistence-unit name="pu1"> &commonmappings; 
> <mapping-file>pu1-mappings.xml</mapping-file> </persistence-unit> 
> <persistence-unit name="pu2"> &commonmappings; 
> <mapping-file>pu2-mappings.xml</mapping-file> </persistence-unit> 
> </persistence-units>
> 
> -Patrick
> 
> On Dec 19, 2007 12:32 AM, Adam Hardy <ad...@cyberspaceroad.org> wrote:
>> I omitted to mention that the pseudo-XML I gave doesn't work and I'm not
>> clear how I can get it to include the other file.
>> 
>> 
>> Adam Hardy on 18/12/07 21:55, wrote:
>>> I have 2 persistence units, which share many of their mapping files, so 
>>> it is more like this:
>>> 
>>> <persistence-unit name="mypu"> <mapping-file>mypu.xml</mapping-file> 
>>> <mapping-file>orm1.xml</mapping-file> 
>>> <mapping-file>orm2.xml</mapping-file> </persistence-unit> 
>>> <persistence-unit name="other"> <mapping-file>other.xml</mapping-file> 
>>> <mapping-file>orm1.xml</mapping-file> 
>>> <mapping-file>orm2.xml</mapping-file> </persistence-unit>
>>> 
>>> and I want to cut out the duplication of the shared mapping files by 
>>> including just 1 seperate xml snippet like this:
>>> 
>>> <persistence-unit name="mypu"> <mapping-file>mypu.xml</mapping-file> 
>>> <xi:include href="shared-mapping.xml"/> </persistence-unit> 
>>> <persistence-unit name="other"> <mapping-file>other.xml</mapping-file> 
>>> <xi:include href="shared-mapping.xml"/> </persistence-unit>
>>> 
>>> 
>>> Michael Dick on 18/12/07 18:26, wrote:
>>>> Hi Adam,
>>>> 
>>>> Something like this should work  : <persistence-unit name="mypu"> 
>>>> <mapping-file>orm1.xml</mapping-file> 
>>>> <mapping-file>orm2.xml</mapping-file> . . . </persistence-unit>
>>>> 
>>>> Is this what you're looking for?
>>>> 
>>>> -Mike
>>>> 
>>>> On Dec 18, 2007 5:59 AM, Adam Hardy <ad...@cyberspaceroad.org>
>>>> wrote:
>>>> 
>>>>> I'm getting nowhere trying to massage my persistence.xml into
>>>>> something that validates and at this point I'm getting spurious
>>>>> errors from Eclipse about the well-formedness of the XML, so I'll ask
>>>>> here to see if anyone's got an example to hand.
>>>>> 
>>>>> I would like to include a list of mapping files in multiple places in
>>>>> my persistence.xml (once in each persistence unit). I tried several 
>>>>> different ideas from the web, but I haven't got anything to validate
>>>>> in my XML editor yet.
>>>>> 
>>>>> i.e. I have a list like this:
>>>>> 
>>>>> 
>>>>> <mapping-file>org/permacode/patternrepo/orm/Category.xml</mapping-file>
>>>>> 
>>>>> 
>>>>> <mapping-file>org/permacode/patternrepo/orm/Market.xml</mapping-file>
>>>>>  <mapping-file>org/permacode/patternrepo/orm/Code.xml</mapping-file>
>>>>> 
>>>>> <mapping-file>org/permacode/patternrepo/orm/TestResult.xml</mapping-file>
>>>>> 
>>>>> 
>>>>> 
>>>>> <mapping-file>org/permacode/patternrepo/orm/TradingParam.xml</mapping-file>
>>>>> 
>>>>> 
>>>>> 
>>>>> which I want to include - I'd be really grateful if someone could 
>>>>> tell me the xml syntax for the include?
> 


Re: initializing EMF with lists of mapping files

Posted by Patrick Linskey <pl...@gmail.com>.
Hi,

Probably the best way to do that is with XML entities:

<!ENTITY commonmappings SYSTEM "commonmappings.xml">
<persistence-units>
    <persistence-unit name="pu1">
        &commonmappings;
        <mapping-file>pu1-mappings.xml</mapping-file>
    </persistence-unit>
    <persistence-unit name="pu2">
        &commonmappings;
        <mapping-file>pu2-mappings.xml</mapping-file>
    </persistence-unit>
</persistence-units>

-Patrick

On Dec 19, 2007 12:32 AM, Adam Hardy <ad...@cyberspaceroad.org> wrote:
> I omitted to mention that the pseudo-XML I gave doesn't work and I'm not clear
> how I can get it to include the other file.
>
>
> Adam Hardy on 18/12/07 21:55, wrote:
> > I have 2 persistence units, which share many of their mapping files, so
> > it is more like this:
> >
> > <persistence-unit name="mypu">
> >     <mapping-file>mypu.xml</mapping-file>
> >     <mapping-file>orm1.xml</mapping-file>
> >     <mapping-file>orm2.xml</mapping-file>
> > </persistence-unit>
> > <persistence-unit name="other">
> >     <mapping-file>other.xml</mapping-file>
> >     <mapping-file>orm1.xml</mapping-file>
> >     <mapping-file>orm2.xml</mapping-file>
> > </persistence-unit>
> >
> > and I want to cut out the duplication of the shared mapping files by
> > including just 1 seperate xml snippet like this:
> >
> > <persistence-unit name="mypu">
> >     <mapping-file>mypu.xml</mapping-file>
> >     <xi:include href="shared-mapping.xml"/>
> > </persistence-unit>
> > <persistence-unit name="other">
> >     <mapping-file>other.xml</mapping-file>
> >     <xi:include href="shared-mapping.xml"/>
> > </persistence-unit>
> >
> >
> > Michael Dick on 18/12/07 18:26, wrote:
> >> Hi Adam,
> >>
> >> Something like this should work  :
> >> <persistence-unit name="mypu">
> >>     <mapping-file>orm1.xml</mapping-file>
> >>     <mapping-file>orm2.xml</mapping-file>
> >>     . . .
> >> </persistence-unit>
> >>
> >> Is this what you're looking for?
> >>
> >> -Mike
> >>
> >> On Dec 18, 2007 5:59 AM, Adam Hardy <ad...@cyberspaceroad.org> wrote:
> >>
> >>> I'm getting nowhere trying to massage my persistence.xml into something
> >>> that
> >>> validates and at this point I'm getting spurious errors from Eclipse
> >>> about
> >>> the
> >>> well-formedness of the XML, so I'll ask here to see if anyone's got an
> >>> example
> >>> to hand.
> >>>
> >>> I would like to include a list of mapping files in multiple places in my
> >>> persistence.xml (once in each persistence unit). I tried several
> >>> different
> >>> ideas
> >>> from the web, but I haven't got anything to validate in my XML editor
> >>> yet.
> >>>
> >>> i.e. I have a list like this:
> >>>
> >>>
> >>> <mapping-file>org/permacode/patternrepo/orm/Category.xml</mapping-file>
> >>>
> >>> <mapping-file>org/permacode/patternrepo/orm/Market.xml</mapping-file>
> >>>     <mapping-file>org/permacode/patternrepo/orm/Code.xml</mapping-file>
> >>>
> >>> <mapping-file>org/permacode/patternrepo/orm/TestResult.xml</mapping-file>
> >>>
> >>>
> >>> <mapping-file>org/permacode/patternrepo/orm/TradingParam.xml</mapping-file>
> >>>
> >>>
> >>> which I want to include - I'd be really grateful if someone could
> >>> tell me
> >>> the
> >>> xml syntax for the include?
> >
> >
>
>



-- 
Patrick Linskey
202 669 5907

Re: initializing EMF with lists of mapping files

Posted by Adam Hardy <ad...@cyberspaceroad.org>.
I omitted to mention that the pseudo-XML I gave doesn't work and I'm not clear 
how I can get it to include the other file.

Adam Hardy on 18/12/07 21:55, wrote:
> I have 2 persistence units, which share many of their mapping files, so 
> it is more like this:
> 
> <persistence-unit name="mypu">
>     <mapping-file>mypu.xml</mapping-file>
>     <mapping-file>orm1.xml</mapping-file>
>     <mapping-file>orm2.xml</mapping-file>
> </persistence-unit>
> <persistence-unit name="other">
>     <mapping-file>other.xml</mapping-file>
>     <mapping-file>orm1.xml</mapping-file>
>     <mapping-file>orm2.xml</mapping-file>
> </persistence-unit>
> 
> and I want to cut out the duplication of the shared mapping files by 
> including just 1 seperate xml snippet like this:
> 
> <persistence-unit name="mypu">
>     <mapping-file>mypu.xml</mapping-file>
>     <xi:include href="shared-mapping.xml"/>
> </persistence-unit>
> <persistence-unit name="other">
>     <mapping-file>other.xml</mapping-file>
>     <xi:include href="shared-mapping.xml"/>
> </persistence-unit>
> 
> 
> Michael Dick on 18/12/07 18:26, wrote:
>> Hi Adam,
>>
>> Something like this should work  :
>> <persistence-unit name="mypu">
>>     <mapping-file>orm1.xml</mapping-file>
>>     <mapping-file>orm2.xml</mapping-file>
>>     . . .
>> </persistence-unit>
>>
>> Is this what you're looking for?
>>
>> -Mike
>>
>> On Dec 18, 2007 5:59 AM, Adam Hardy <ad...@cyberspaceroad.org> wrote:
>>
>>> I'm getting nowhere trying to massage my persistence.xml into something
>>> that
>>> validates and at this point I'm getting spurious errors from Eclipse 
>>> about
>>> the
>>> well-formedness of the XML, so I'll ask here to see if anyone's got an
>>> example
>>> to hand.
>>>
>>> I would like to include a list of mapping files in multiple places in my
>>> persistence.xml (once in each persistence unit). I tried several 
>>> different
>>> ideas
>>> from the web, but I haven't got anything to validate in my XML editor 
>>> yet.
>>>
>>> i.e. I have a list like this:
>>>
>>>
>>> <mapping-file>org/permacode/patternrepo/orm/Category.xml</mapping-file>
>>>     
>>> <mapping-file>org/permacode/patternrepo/orm/Market.xml</mapping-file>
>>>     <mapping-file>org/permacode/patternrepo/orm/Code.xml</mapping-file>
>>>
>>> <mapping-file>org/permacode/patternrepo/orm/TestResult.xml</mapping-file> 
>>>
>>>
>>> <mapping-file>org/permacode/patternrepo/orm/TradingParam.xml</mapping-file> 
>>>
>>>
>>> which I want to include - I'd be really grateful if someone could 
>>> tell me
>>> the
>>> xml syntax for the include?
> 
> 


Re: initializing EMF with lists of mapping files

Posted by Adam Hardy <ad...@cyberspaceroad.org>.
I have 2 persistence units, which share many of their mapping files, so it is 
more like this:

<persistence-unit name="mypu">
     <mapping-file>mypu.xml</mapping-file>
     <mapping-file>orm1.xml</mapping-file>
     <mapping-file>orm2.xml</mapping-file>
</persistence-unit>
<persistence-unit name="other">
     <mapping-file>other.xml</mapping-file>
     <mapping-file>orm1.xml</mapping-file>
     <mapping-file>orm2.xml</mapping-file>
</persistence-unit>

and I want to cut out the duplication of the shared mapping files by including 
just 1 seperate xml snippet like this:

<persistence-unit name="mypu">
     <mapping-file>mypu.xml</mapping-file>
     <xi:include href="shared-mapping.xml"/>
</persistence-unit>
<persistence-unit name="other">
     <mapping-file>other.xml</mapping-file>
     <xi:include href="shared-mapping.xml"/>
</persistence-unit>


Michael Dick on 18/12/07 18:26, wrote:
> Hi Adam,
> 
> Something like this should work  :
> <persistence-unit name="mypu">
>     <mapping-file>orm1.xml</mapping-file>
>     <mapping-file>orm2.xml</mapping-file>
>     . . .
> </persistence-unit>
> 
> Is this what you're looking for?
> 
> -Mike
> 
> On Dec 18, 2007 5:59 AM, Adam Hardy <ad...@cyberspaceroad.org> wrote:
> 
>> I'm getting nowhere trying to massage my persistence.xml into something
>> that
>> validates and at this point I'm getting spurious errors from Eclipse about
>> the
>> well-formedness of the XML, so I'll ask here to see if anyone's got an
>> example
>> to hand.
>>
>> I would like to include a list of mapping files in multiple places in my
>> persistence.xml (once in each persistence unit). I tried several different
>> ideas
>> from the web, but I haven't got anything to validate in my XML editor yet.
>>
>> i.e. I have a list like this:
>>
>>
>> <mapping-file>org/permacode/patternrepo/orm/Category.xml</mapping-file>
>>     <mapping-file>org/permacode/patternrepo/orm/Market.xml</mapping-file>
>>     <mapping-file>org/permacode/patternrepo/orm/Code.xml</mapping-file>
>>
>> <mapping-file>org/permacode/patternrepo/orm/TestResult.xml</mapping-file>
>>
>> <mapping-file>org/permacode/patternrepo/orm/TradingParam.xml</mapping-file>
>>
>> which I want to include - I'd be really grateful if someone could tell me
>> the
>> xml syntax for the include?


Re: initializing EMF with lists of mapping files

Posted by Michael Dick <mi...@gmail.com>.
Hi Adam,

Something like this should work  :
<persistence-unit name="mypu">
    <mapping-file>orm1.xml</mapping-file>
    <mapping-file>orm2.xml</mapping-file>
    . . .
</persistence-unit>

Is this what you're looking for?

-Mike

On Dec 18, 2007 5:59 AM, Adam Hardy <ad...@cyberspaceroad.org> wrote:

> I'm getting nowhere trying to massage my persistence.xml into something
> that
> validates and at this point I'm getting spurious errors from Eclipse about
> the
> well-formedness of the XML, so I'll ask here to see if anyone's got an
> example
> to hand.
>
> I would like to include a list of mapping files in multiple places in my
> persistence.xml (once in each persistence unit). I tried several different
> ideas
> from the web, but I haven't got anything to validate in my XML editor yet.
>
> i.e. I have a list like this:
>
>
> <mapping-file>org/permacode/patternrepo/orm/Category.xml</mapping-file>
>     <mapping-file>org/permacode/patternrepo/orm/Market.xml</mapping-file>
>     <mapping-file>org/permacode/patternrepo/orm/Code.xml</mapping-file>
>
> <mapping-file>org/permacode/patternrepo/orm/TestResult.xml</mapping-file>
>
> <mapping-file>org/permacode/patternrepo/orm/TradingParam.xml</mapping-file>
>
> which I want to include - I'd be really grateful if someone could tell me
> the
> xml syntax for the include?
>
> Thanks
> Adam
>

Re: initializing EMF with lists of mapping files

Posted by Adam Hardy <ad...@cyberspaceroad.org>.
I'm getting nowhere trying to massage my persistence.xml into something that 
validates and at this point I'm getting spurious errors from Eclipse about the 
well-formedness of the XML, so I'll ask here to see if anyone's got an example 
to hand.

I would like to include a list of mapping files in multiple places in my 
persistence.xml (once in each persistence unit). I tried several different ideas 
from the web, but I haven't got anything to validate in my XML editor yet.

i.e. I have a list like this:

     <mapping-file>org/permacode/patternrepo/orm/Category.xml</mapping-file>
     <mapping-file>org/permacode/patternrepo/orm/Market.xml</mapping-file>
     <mapping-file>org/permacode/patternrepo/orm/Code.xml</mapping-file>
     <mapping-file>org/permacode/patternrepo/orm/TestResult.xml</mapping-file>
     <mapping-file>org/permacode/patternrepo/orm/TradingParam.xml</mapping-file>

which I want to include - I'd be really grateful if someone could tell me the 
xml syntax for the include?

Thanks
Adam

Re: initializing EMF with lists of mapping files

Posted by Adam Hardy <ad...@cyberspaceroad.org>.
>>
This is something I've been trying to sort out for a while - 
every now and then it catches me out and I waste time tracking 
down my error to the omission of a new entity mapping file from 
one of the persistence units in my persistence.xml. 

Below, it's suggested that I can feed JPA the list of mapping files 
via the EntityManagerFactory.createEntityManager() method. I tried 
this out with no success. I doesn't seem possible, surely?

The alternative is to use XML entities - has anybody done this with 
success?

Thanks
Adam

Patrick Linskey <pl...@...> writes:
> You can do this with the
> EntityManagerFactory.createEntityManager(String puName, Map props)
> signature.
> 
> Alternately, you can use XML entities to define the shared mappings
> outside of your persistence units and refer to them in multiple
> places.
> 
> -Patrick
> 
> On 10/29/07, Adam Hardy <ad...@...> wrote:
> > Hi List,
> >
> > I am running JPA with a set of mapping files, one for each table in the 
database
> >   plus a few for queries, and in my test environment I have additional 
mapping
> > files that aren't required in container and in fact I would like to exclude.
> >
> > So I made a second test persistence.xml and now I find though that I have to

> > maintain 2 lists of mapping files.
> >
> > I would like to initialize the entity manager factory programmatically to add
> > the main list of mapping files, and then in testing, to add the extra 
mapping
> > files as well.
> >
> > There seems to be no method on the API where I do that programmatically 
though.
> > Is that correct or have I overlooked something?
> >
> >
> > Regards
> > Adam
> >
> 





Re: initializing EMF with lists of mapping files

Posted by Patrick Linskey <pl...@gmail.com>.
Hi,

You can do this with the
EntityManagerFactory.createEntityManager(String puName, Map props)
signature.

Alternately, you can use XML entities to define the shared mappings
outside of your persistence units and refer to them in multiple
places.

-Patrick

On 10/29/07, Adam Hardy <ad...@cyberspaceroad.com> wrote:
> Hi List,
>
> I am running JPA with a set of mapping files, one for each table in the database
>   plus a few for queries, and in my test environment I have additional mapping
> files that aren't required in container and in fact I would like to exclude.
>
> So I made a second test persistence.xml and now I find though that I have to
> maintain 2 lists of mapping files.
>
> I would like to initialize the entity manager factory programmatically to add
> the main list of mapping files, and then in testing, to add the extra mapping
> files as well.
>
> There seems to be no method on the API where I do that programmatically though.
> Is that correct or have I overlooked something?
>
>
> Regards
> Adam
>


-- 
Patrick Linskey
202 669 5907