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
To access the DB I use Springs dependency injection to inject a JPA entity Manager.Code:<?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http://java.sun.com/x/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>
I define my bean like this
and then I inject the entity manager like thisCode:<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>
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.Code:@PersistenceContext private EntityManager entityManager;
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/8...ory-at-runtime


Reply With Quote
