You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by rde8026 <rd...@gmail.com> on 2008/09/19 05:28:24 UTC
EntityManager not picking up Map properties
I'm using Hibernate as my JPA provider in a Stateless EJB. I need to add the
hibernate.default_catalog property to the EntityManager based on the dialect
being used (i.e. SQL Server = dbo). I'm injecting the EntityManagerFactory
and trying to construct an EntityManager based off that but passing a
HashMap to it with that single property...and its not pre-pending the sql
statements correctly. If I do it via the persistence.xml file it
works....any thoughts?
Here is a code snippet..
Map<String, String> props = new HashMap<String, String>();
props.put("hibernate.default_catalog", "dbo");
em = emf.createEntityManager(props);
Thanks for any advice!
--
View this message in context: http://www.nabble.com/EntityManager-not-picking-up-Map-properties-tp19565672p19565672.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: EntityManager not picking up Map properties
Posted by David Blevins <da...@visi.com>.
On Sep 18, 2008, at 10:28 PM, rde8026 wrote:
> I'm using Hibernate as my JPA provider in a Stateless EJB. I need
> to add the
> hibernate.default_catalog property to the EntityManager based on the
> dialect
> being used (i.e. SQL Server = dbo). I'm injecting the
> EntityManagerFactory
> and trying to construct an EntityManager based off that but passing a
> HashMap to it with that single property...and its not pre-pending
> the sql
> statements correctly. If I do it via the persistence.xml file it
> works....any thoughts?
>
> Here is a code snippet..
>
> Map<String, String> props = new HashMap<String, String>();
> props.put("hibernate.default_catalog", "dbo");
> em = emf.createEntityManager(props);
Likely a bug in hibernate as that call goes directly to them. We get
the hibernate EntityManagerFactory via a call like:
PersistenceProvider persistenceProvider = (PersistenceProvider)
clazz.newInstance();
EntityManagerFactory emf =
persistenceProvider.createContainerEntityManagerFactory(unitInfo, new
HashMap());
And the persistence.xml data is in the PersistenceUnitInfo
implementation we create and hand to the persistence provider
(Hibernate in this case). Seems they only support that property (or
perhaps all properties) via the call above and not via the
EntityManagerFactory createEntityManager method.
-David