Hi guys,
I am using Hibernate 3.5.6 + Spring 3.0.5 (and JPA)
I am currently searching for a way to reload my hibernate mapping information at runtime.
All hibernate classes + annotations are in a seperate .jar file which I use in my persistence.xml (JPA) like this
Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="JPAService" transaction-type="RESOURCE_LOCAL">
<jar-file>WEB-INF/lib/mapping.jar</jar-file>
</persistence-unit>
</persistence>
To access the DB I use Springs dependency injection to inject a JPA entity Manager.
I define my bean like this
Code:
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceXmlLocation" value="/WEB-INF/config.incb/persistence.xml" />
<property name="persistenceUnitName" value="JPAService" />
<property name="persistenceProviderClass" value="org.hibernate.ejb.HibernatePersistence"/>
<property name="dataSource" ref="dataSource" />
<property name="jpaDialect">
<bean class="org.unodc.incbszdb.hibernate.HibernateExtendedJpaDialect" />
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialectWithGroupConcat</prop>
<prop key="hibernate.hbm2ddl.auto">none</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
and then I inject the entity manager like this
Code:
@PersistenceContext
private EntityManager entityManager;
Now every time I add a new property to my mappings I have to restart my server. Obviously a situation I can not really live with.
I would rather just refresh my mapping information and keep the server up and running.
Can somebody maybe give me a hint how I can change the mapping without restarting the server...
Any help is more than welcome.
PS:
More information can also be found in a Stackoverflow thread I started.
There are also some links to similar questions from Hibernate/Spring and Stackoverflow forum, but they didn't provide a proper solution.
http://stackoverflow.com/questions/8671 ... at-runtime