database dependent queries

3 messages Options
Embed this post
Permalink
Michael Simons

database dependent queries

Reply Threaded More More options
Print post
Permalink
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
Miłosz Tylenda

Re: database dependent queries

Reply Threaded More More options
Print post
Permalink
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
>
Michael Simons

Re: database dependent queries

Reply Threaded More More options
Print post
Permalink
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