Hi,
I'm building a dynamic database tool, this tool is part of a customized web tool framework, built over spring framework (
www.springframework.org) and it is using hibernate as persistence mechanism.
The tool has the funcionality to define a entity, properties or relationships, and then it build dynamically the Entity bytecode, and create related tables and hibernate mappings. To make this work, we need a way to hibernate handle dynamic mapping modifications, but after read a lot, i see that this is not a present feature nor a planned future feature.
Now i must find a way to implement dynamic mapping in hibernate. After searching for ways to do this i stuck with some aproaches and lot of questions.
1st - Use the hibernate dynamic-class or dynamic-component to implement the idea, but this feature is not well documented, do not have examples and i don't know if mapping modification at runyime is possible (I think not).
2st - I have a already running session factory (1st - SF), this session factory is reponsible for all my framework entities, i think in creating a separate SF (2nd) and bind two to a JTA transaction platform. But, my second SF, that can be reloaded, must have access/association with the 1st session factory. Example: User Entity on 1st SF is references by DynTbl001 on 2nd SF. Is there a way to do this ? Can two SF be linked ? Is there a way to detect a loading or saving operation in on SF and redirect to other SF ?
3st - Someone in some forum, tell me to build a new SF on mapping changes, and then let the new SF to serve new Sessions to Bussiness Objects. Yes it could be done, but i have to manage Session Factory through a wraper object, and must manage session openning and closing. This because, the wrapper acts as a Delegate Object, delegating call to one SF instance. On reloading this instance continues normal operation until that NEW SF becomes ready. The problem is in closing first SF to release resources i need to manage how much sessions if open and related to 1st SF. This approach, clear all caching, and seems that already detached collections can not be able to be reassigned to the new Session of the new SF.