-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How to reload Mapping information at runtime
PostPosted: Mon Jan 09, 2012 2:06 pm 
Newbie

Joined: Mon Jan 09, 2012 1:57 pm
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.