You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Stanczak Group <ju...@stanczakgroup.com> on 2007/09/11 03:29:05 UTC

Non-EE mapping classes?

How do I map classes if I'm not using persistence.xml or EE? Usually you 
use xml like this:
<class>tutorial.Animal</class>
but I'm using a properties file.

-- 
Justin Stanczak
Stanczak Group
812-735-3600

"All that is necessary for the triumph of evil is that good men do nothing."
Edmund Burke


Re: Non-EE mapping classes?

Posted by Patrick Linskey <pl...@gmail.com>.
Actually, you should be able to call
Persistence.createEntityManagerFactory("foo", map), where "foo" is the
name of your persistence unit in a META-INF/persistence.xml file.

-Patrick

On 9/10/07, Gene Wu <ge...@hotmail.com> wrote:
> Yes, I think so. and you have to use OpenJPA specified APIs instead of JPA standard one.
>
> Here is an example:
> OpenJPAPersistence.getEntityFactory(map);
>
> The map instance contains the properties from local file.
>
> Thanks
>
> Gene.
>
> > Date: Mon, 10 Sep 2007 20:58:11 -0500
> > From: justin@stanczakgroup.com
> > To: users@openjpa.apache.org
> > Subject: Re: Non-EE mapping classes?
> >
> > So where can I put this xml file so it will work in my jar? I'm assuming
> > I can then load a properties file that will override the xml settings?
> >
> > Gene Wu wrote:
> > > In my opinion, for OpenJPA, you have to use one persistence.xml. Here is the reason.
> > >
> > > You might create a persistence entity manager without persistence.xml, but OpenJPA used to enhance java entity classes. The JAVA agent of OpenJPA (Runtime Enhancement) needs at least one persistence.xml (or orm.xml). Meanwhile, runtime enhancement has the minimum requirement on configuration file, even you didn't put your entity class in that file.
> > >
> > > Thanks,
> > >
> > > Gene.
> > >
> > >
> > >
> > >
> > >> Date: Mon, 10 Sep 2007 20:29:05 -0500
> > >> From: justin@stanczakgroup.com
> > >> To: users@openjpa.apache.org
> > >> Subject: Non-EE mapping classes?
> > >>
> > >> How do I map classes if I'm not using persistence.xml or EE? Usually you
> > >> use xml like this:
> > >> <class>tutorial.Animal</class>
> > >> but I'm using a properties file.
> > >>
> > >> --
> > >> Justin Stanczak
> > >> Stanczak Group
> > >> 812-735-3600
> > >>
> > >> "All that is necessary for the triumph of evil is that good men do nothing."
> > >> Edmund Burke
> > >>
> > >>
> > >
> > > _________________________________________________________________
> > > Gear up for Halo(r) 3 with free downloads and an exclusive offer. It's our way of saying thanks for using Windows Live™.
> > > http://gethalo3gear.com?ocid=SeptemberWLHalo3_WLHMTxt_2
> > >
> >
> > --
> > Justin Stanczak
> > Stanczak Group
> > 812-735-3600
> >
> > "All that is necessary for the triumph of evil is that good men do nothing."
> > Edmund Burke
> >
>
> _________________________________________________________________
> More photos; more messages; more whatever – Get MORE with Windows Live™ Hotmail(r). NOW with 5GB storage.
> http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_TAGHM_migration_HM_mini_5G_0907


-- 
Patrick Linskey
202 669 5907

RE: Non-EE mapping classes?

Posted by Gene Wu <ge...@hotmail.com>.
Yes, I think so. and you have to use OpenJPA specified APIs instead of JPA standard one.

Here is an example:
OpenJPAPersistence.getEntityFactory(map);

The map instance contains the properties from local file.

Thanks

Gene.

> Date: Mon, 10 Sep 2007 20:58:11 -0500
> From: justin@stanczakgroup.com
> To: users@openjpa.apache.org
> Subject: Re: Non-EE mapping classes?
> 
> So where can I put this xml file so it will work in my jar? I'm assuming 
> I can then load a properties file that will override the xml settings?
> 
> Gene Wu wrote:
> > In my opinion, for OpenJPA, you have to use one persistence.xml. Here is the reason.
> >
> > You might create a persistence entity manager without persistence.xml, but OpenJPA used to enhance java entity classes. The JAVA agent of OpenJPA (Runtime Enhancement) needs at least one persistence.xml (or orm.xml). Meanwhile, runtime enhancement has the minimum requirement on configuration file, even you didn't put your entity class in that file.
> >
> > Thanks,
> >
> > Gene.
> >
> >
> >
> >   
> >> Date: Mon, 10 Sep 2007 20:29:05 -0500
> >> From: justin@stanczakgroup.com
> >> To: users@openjpa.apache.org
> >> Subject: Non-EE mapping classes?
> >>
> >> How do I map classes if I'm not using persistence.xml or EE? Usually you 
> >> use xml like this:
> >> <class>tutorial.Animal</class>
> >> but I'm using a properties file.
> >>
> >> -- 
> >> Justin Stanczak
> >> Stanczak Group
> >> 812-735-3600
> >>
> >> "All that is necessary for the triumph of evil is that good men do nothing."
> >> Edmund Burke
> >>
> >>     
> >
> > _________________________________________________________________
> > Gear up for Halo® 3 with free downloads and an exclusive offer. It’s our way of saying thanks for using Windows Live™.
> > http://gethalo3gear.com?ocid=SeptemberWLHalo3_WLHMTxt_2
> >   
> 
> -- 
> Justin Stanczak
> Stanczak Group
> 812-735-3600
> 
> "All that is necessary for the triumph of evil is that good men do nothing."
> Edmund Burke
> 

_________________________________________________________________
More photos; more messages; more whatever – Get MORE with Windows Live™ Hotmail®. NOW with 5GB storage.
http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_TAGHM_migration_HM_mini_5G_0907

Re: Non-EE mapping classes?

Posted by Stanczak Group <ju...@stanczakgroup.com>.
So where can I put this xml file so it will work in my jar? I'm assuming 
I can then load a properties file that will override the xml settings?

Gene Wu wrote:
> In my opinion, for OpenJPA, you have to use one persistence.xml. Here is the reason.
>
> You might create a persistence entity manager without persistence.xml, but OpenJPA used to enhance java entity classes. The JAVA agent of OpenJPA (Runtime Enhancement) needs at least one persistence.xml (or orm.xml). Meanwhile, runtime enhancement has the minimum requirement on configuration file, even you didn't put your entity class in that file.
>
> Thanks,
>
> Gene.
>
>
>
>   
>> Date: Mon, 10 Sep 2007 20:29:05 -0500
>> From: justin@stanczakgroup.com
>> To: users@openjpa.apache.org
>> Subject: Non-EE mapping classes?
>>
>> How do I map classes if I'm not using persistence.xml or EE? Usually you 
>> use xml like this:
>> <class>tutorial.Animal</class>
>> but I'm using a properties file.
>>
>> -- 
>> Justin Stanczak
>> Stanczak Group
>> 812-735-3600
>>
>> "All that is necessary for the triumph of evil is that good men do nothing."
>> Edmund Burke
>>
>>     
>
> _________________________________________________________________
> Gear up for Halo® 3 with free downloads and an exclusive offer. It’s our way of saying thanks for using Windows Live™.
> http://gethalo3gear.com?ocid=SeptemberWLHalo3_WLHMTxt_2
>   

-- 
Justin Stanczak
Stanczak Group
812-735-3600

"All that is necessary for the triumph of evil is that good men do nothing."
Edmund Burke


RE: Non-EE mapping classes?

Posted by Gene Wu <ge...@hotmail.com>.
In my opinion, for OpenJPA, you have to use one persistence.xml. Here is the reason.

You might create a persistence entity manager without persistence.xml, but OpenJPA used to enhance java entity classes. The JAVA agent of OpenJPA (Runtime Enhancement) needs at least one persistence.xml (or orm.xml). Meanwhile, runtime enhancement has the minimum requirement on configuration file, even you didn't put your entity class in that file.

Thanks,

Gene.



> Date: Mon, 10 Sep 2007 20:29:05 -0500
> From: justin@stanczakgroup.com
> To: users@openjpa.apache.org
> Subject: Non-EE mapping classes?
> 
> How do I map classes if I'm not using persistence.xml or EE? Usually you 
> use xml like this:
> <class>tutorial.Animal</class>
> but I'm using a properties file.
> 
> -- 
> Justin Stanczak
> Stanczak Group
> 812-735-3600
> 
> "All that is necessary for the triumph of evil is that good men do nothing."
> Edmund Burke
> 

_________________________________________________________________
Gear up for Halo® 3 with free downloads and an exclusive offer. It’s our way of saying thanks for using Windows Live™.
http://gethalo3gear.com?ocid=SeptemberWLHalo3_WLHMTxt_2