-->
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.  [ 5 posts ] 
Author Message
 Post subject: Programmatic configuration
PostPosted: Fri Dec 05, 2003 1:11 pm 
Regular
Regular

Joined: Tue Sep 02, 2003 5:09 pm
Posts: 81
Location: Whitefish Montana
We have several standalone systems using Hibernate that load a few classes/mappings. I have been adding classes to the mapping dynamically by doing something like this:

Code:
            if (this.configuration.getClassMapping(clazz) == null) {
                this.configuration.addClass(clazz);
                this.sessionFactory = this.configuration.buildSessionFactory();
            }


This works very well -- except when you have open sessions. Any open sessions now have a stale copy of the session factory. Is there some sanctioned way to rebuild the session factory with the new configuration information? If there isn't does it make sense support rebuilding an existing sessionFactory? something like
Code:
configuration.rebuildSessionFactory(this.sessionFactory)
.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 05, 2003 1:38 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
If you mean previous opened session (with the old sessionFactory) keep staled meta model.
Then there is no way to associate old sessions with the new one. It would certainly break session cache and lot's of stuff.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 05, 2003 2:21 pm 
Regular
Regular

Joined: Tue Sep 02, 2003 5:09 pm
Posts: 81
Location: Whitefish Montana
And it does break lots of stuff. What I wonder is if it would work to rebuild/append to the internal maps in an existing session factory. All existing meta information would remain the same just adding new meta information. Looking at the code it seems that it shouldn't break anything. I didn't look at the cache but that could be flushed in this case and seems to be existing/tested functionality.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 05, 2003 9:50 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
No way. This would break a million things. What are you worrying about old sessions for anyway? Sessions are meant to be short-lived things!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 07, 2003 1:35 pm 
Regular
Regular

Joined: Tue Sep 02, 2003 5:09 pm
Posts: 81
Location: Whitefish Montana
I was trying to add classes just-in-time. For an application I am working on I have three choices - configure just-in-time, configure all needed components and build a new factory each time, or create the application as a daemon. Originally, I went with the just-in-tim option but now I am configuring all necessary components and building a new factory.

In this case I was stepping through the SessionFactoryImpl in debug and don't see where adding to the meta data maps would break anything -- but I'll take your word for it since you wrote the code.


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