-->
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.  [ 3 posts ] 
Author Message
 Post subject: Add table at runtime to existing db schema
PostPosted: Tue Mar 03, 2009 5:24 am 
Newbie

Joined: Tue Mar 03, 2009 4:33 am
Posts: 1
Hi,

I’m a relative beginner with hibernate but I’m working on an application that uses hibernate3 annotations. Currently we have a need to add a table to the existing database schema at runtime.

My understanding is that hibernate builds up a collection of all the annotated classes as part of the AnnotationConfiguration therefore is it even possible to add classes to this list and “re-build” the mappings to include a new table?

Any advice would be appreciated.

Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 03, 2009 6:10 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
Changing an existing Configuration of a SessionFactory is not possible. But you can create a new Configuration, add all mapping files and create a new SessionFactory:
Code:
      Configuration cfg = new Configuration();
      //getMappingFiles returns a list of File-Objects
      for (String s : getMappingFiles()) {
         cfg.addFile(s);
      }
      cfg.configure();

      SessionFactory factory = cfg.buildSessionFactory();

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 03, 2009 6:14 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
Changing an existing Configuration of a SessionFactory is not possible. But you can create a new Configuration, add all mapping files and create a new SessionFactory:
Code:
      Configuration cfg = new Configuration();
      //getMappingFiles returns a list of File-Objects
      for (String s : getMappingFiles()) {
         cfg.addFile(s);
      }
      cfg.configure();

      SessionFactory factory = cfg.buildSessionFactory();

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.