tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From quizzical <quixop...@gmail.com>
Subject Re: Configuring hibernate properties in unit tests
Date Wed, 03 Sep 2008 14:47:26 GMT



David Blevins wrote:
> 
> 
> I went ahead and hacked something up here.  Now you can override  
> properties on the persistence-units just as you can override the  
> properties of <Resource> and <Container> objects.
> 
> So with a unit like so:
> 
>    <persistence-unit name="movie-unit">
>      <provider>org.hibernate.ejb.HibernatePersistence</provider>
>      <jta-data-source>movieDatabase</jta-data-source>
>      <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
> 
>      <properties>
>        <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
>        <property name="hibernate.dialect" value="mysql"/>
>      </properties>
>    </persistence-unit>
> 
> 
> You can override it in your test case like so:
> 
>    Properties p = new Properties();
>    p.put(Context.INITIAL_CONTEXT_FACTORY,  
> "org.apache.openejb.client.LocalInitialContextFactory");
> 
>    p.put("movie-unit.hibernate.dialect", "hsql");
> 
>    Context context = new InitialContext(p);
> 
> So the override format is "<unitName>.<propertyName>=<valueName>"
> 
> I've uploaded new 3.1-SNAPSHOTs to the apache snapshot repo [1].  Give  
> them a try and let us know how it goes.
> 
> -David
> 
> [1]
> http://people.apache.org/repo/m2-snapshot-repository/org/apache/openejb/
> 
> 
> 

That looks good, i'll give it a try this evening.

-- 
View this message in context: http://www.nabble.com/Configuring-hibernate-properties-in-unit-tests-tp19167232p19290840.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Mime
View raw message