Hello,
I'm trying to see if I could use Hibernate in my development, and I'm trying to see if it could fit my needs but I'm a bit lost.
I'm working on an application that perform it's own O/R mapping. This application is storing metadata in a mysql db, and generate the data tables thanks to those metadata.
How does it work ?
Let's talk about an object class I need to persist :
MyObject
My class can have different definition from one database to another :
Code:
public class MyObject // Definition for the database 1
{
private String fieldA;
private float fieldB;
}
public class MyObject // Definition for the database 2
{
private String fieldA;
private int fieldB;
private int fieldC;
}
What does it means ?I have some metadata informations that are telling me that :
-fieldA represent the same data in the 2 definition
-fieldB represent the same data but encoded differently
-fieldC is an extra information provided in db2
What do I need ?In my application I can change the metadata definition. My application automatically update the db table structure without losing data.
example :Code:
I migrate a db1 structure to a db2 structure :
MyObject table before :
+--------+--------+
| fieldA | fieldB |
+--------+--------+
| test | 3.14 |
MyObject table after :
+--------+--------+--------+
| fieldA | fieldB | fieldC |
+--------+--------+--------+
| test | 3 | null |
This is an example, I could need to migrate a db2 structure to a db1 structure.
Finally, my question is...
I've search in the documentation how hibernate was handling that kind of stuff, but I don't know where to start and I haven't been able to find something. I guess there's a mechanism to allow the persisted object to evoluate from one version to another, and to update the db table, but I'm lost...
Does somebody could give me an hint, a keyword, anything ?