You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Michael Simons <mi...@optitool.de> on 2009/06/10 12:03:29 UTC

database dependent queries

Hello,

We need to use database dependent native queries ("fast lane reader pattern"). Therefore we need
to load the appropriate statements stored e.g. in a properties file, the name of which is
derived from the database (e.g. "sqlserver.sql")
I wanted to determine the name by evaluating
entityManagerFactory.getProperties ().get("Platform");

Running this standalone works but within a bean I don't have access to the EMF, do I?
Is there another to determine which database is in use?

kind regards, Michael

Re: database dependent queries

Posted by Michael Simons <mi...@optitool.de>.
Miłosz Tylenda schrieb:
> Hi Michael,
> 
> Have you tried the @PersistenceUnit inside a bean:
> 
> @PersistenceUnit EntityManagerFactory emf
> 
> This should inject the EMF into the bean.

and so it does, thanks a lot.

Michael

Re: database dependent queries

Posted by Miłosz Tylenda <mt...@o2.pl>.
Hi Michael,

Have you tried the @PersistenceUnit inside a bean:

@PersistenceUnit EntityManagerFactory emf

This should inject the EMF into the bean.

Cheers,
Milosz


> Hello,
> 
> We need to use database dependent native queries ("fast lane reader pattern"). Therefore we need
> to load the appropriate statements stored e.g. in a properties file, the name of which is
> derived from the database (e.g. "sqlserver.sql")
> I wanted to determine the name by evaluating
> entityManagerFactory.getProperties ().get("Platform");
> 
> Running this standalone works but within a bean I don't have access to the EMF, do I?
> Is there another to determine which database is in use?
> 
> kind regards, Michael
>