Dynamic ORM entity class generation

Hi,

For a client I need to support the following using either Hibernate or some other variant maybe using CGLIB or ASM or freemaker:

The system should support update of the database schema and Hibernate mapping at runtime. Meaning, if I have a Hibernate entity "Animal" with properties A and B I should support the addition and deletion of properties during runtime. e.g. after the transformation the Entity can have property A deleted and property C added. This means of course that :

1-The Entity *Class* itself should be re-generated in memory on the fly with **JPA annotations** for each field. I started testing using CGLIB and one other option is FreeMaker for generating a java source file and then compiling it at runtime.

Recommendations are highly regarded.

2-After that I need somehow to unload the existing "Animal" instances, stop all pending transactions which reference those classes and then

3-Use the newly generated "Animal" Class, load it into the correct ClassLoader and then generate matching RDBMS schema using "ddl2hbm".

4- I guess should also re-initialize the hibernate session factory which is loaded with wrong Class definitions.

there is also a need to be able to generate ORM entities completely from scratch: meaning, I don't even know the name of the table and the types and number of the fields.

Dynamic update of the database schema and in-memory hibernate mapping is not straightforward to develop. Which mechanism would I use for blocking access to the system until a database schema update has been performed?
How would you approach this issue? would you use CGLIB/ASM/Javaassist? some other API that you know is working for some other Client?
I am not sure I want the Bytecode rout, see for instance: http://code.google.com/p/google-guice/source/browse/trunk/src/com/google/inject/internal/BytecodeGen.java

Please reply only if you have a knowledgeable answer :)

Thank you for your interest!

We will contact you as soon as possible.

FOR MORE DETAILS CONTACT US

Please leave your details and we’ll get back to you as soon as possible

Oops, something went wrong
Please try again or contact us by email at info@tikalk.com
Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at info@tikalk.com