You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by David Blevins <da...@visi.com> on 2008/10/09 10:05:00 UTC

Re: EntityManager not picking up Map properties

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