-->
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.  [ 2 posts ] 
Author Message
 Post subject: Changing schema at runtime
PostPosted: Thu Apr 07, 2005 1:40 am 
Regular
Regular

Joined: Thu Feb 19, 2004 4:48 am
Posts: 62
I wonder, if it is possible to change the schema at runtime without restarting the hibernate application? Here is what I want to do:

- programmatically create a new table
- dynamically create a new class
- compile the class using javac.compile(args);
- create a <class>.hbm.xml
- get a handle to the new class with Class clazz = Class.forName(classname);
- *somehow* tell hibernate to use this new class without shutting it down


Is it possible to simply call

cfg.addAnnotatedClass(clazz);

and than call .buildSessionFactory(); again?

Are there any fundamental problems to expect if the session-factory is rebuild at runtime? Is there a way to to terminate/invalidate all sessions that where acquired through this sessionFactory?

Has anyone already tried this approach?

thx for any help
stf


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 07, 2005 10:48 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
What I would do is
letting the old sf
in the mean time creating a new sf
when the new sf is ready
put the new one in the JNDI

The newly opened sessions will use the new config.

_________________
Emmanuel


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

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.