At our company we use Spring 3 / hibernate 3.6.10 to create both static and dynamic tables. The reason for having dynamic tables is that we want a user to be able to access a dynamic table outside the application. So a dynamic table can be access by : select column1,column2 from dynamictable1 . This gives the user a simple way to access a dynamic table. We know hibernate provides a mapping model but this is not adequate for our purposes.
We have created two session factories:
- one for the "normal" static table structure - one for dynamic tables.
We determine the structure of a dynamic table at runtime. The dynamic tables are created by using javassist to create a class with proper hibernate annotations like @Entity and @OneToMany After creation of the class we call org.hibernate.cfg.Configuration.addAnnotatedClass and do a rebuild of the sessionfactory. The creation of new dynamic tables can happen anytime.
I've created a custom transactionmanager which administers the current open transactions and uses a stack to store rebuild sessionfactories. When a new table is needed a sessionfactory is rebuilt put not yet made active. When there are no transactions open, the sessionfactory is replaced. We are concerned about the stability of the application when the replace is take place.
The question is what will happen in a multiuser environment when we replace the sessionfactory?
Last edited by mtolhuisen on Thu Sep 26, 2013 2:13 am, edited 1 time in total.
|