Help

Controls

PermLinkWikiLink

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

Forum: Seam Users Forum ListTopic List
16. Jun 2009, 22:38 America/New_York | Link

A typical part of a persistence.xml looks like

<persistence-unit name="db">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/dbDatasource</jta-data-source>
<properties>
<property name="hibernate.cache.use_second_level_cache" value="true" />
<property name="hibernate.hbm2ddl.auto" value="update" />
</persistence-unit>
..


The question I have is, how to dynamic configure a property that is in the given file. So no hardcoded 'hibernate.hbm2ddl.auto' value 'update' but defined in an external properties file.

Thanks in advance.

4 Replies:
17. Jun 2009, 03:40 America/New_York | Link

What do you mean by dynamic? You can replace those at build/package time using Ant or Maven filtering. That is not completely 'dynamic', but will do if you just want different configurations (testing, release, etc.)

HTH

17. Jun 2009, 08:54 America/New_York | Link

In my current seam application I have an external components.xml (located in jboss/server/default/conf) file to configure the application for a particular environment. By 'dynamic' I mean a similar configuration possibility.

I use jboss-4.2.3-GA and seam 2.1.1-GA

17. Jun 2009, 09:21 America/New_York | Link

Well JPA looks for persistence.xml on the classpath, to you could probably externalize it, like you did with components.xml. Depending on your application structure, you may run into problems, though.

So if have different environments, a separate build for each one would be the safest thing.

17. Jun 2009, 10:08 America/New_York | Link

Well, I think u need to create persistence class manuallly as a java class and register it.

Here i found some example, but u need to find it in google how to create persistence provider.

http://forums.java.net/jive/thread.jspa?threadID=61175&tstart=0