Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.0.5
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
I have a versioning requirement like this. (This is not versioning of an object but it is versioning of the entire application.) Let us assume you have a schema like this,
User -> Order -> OrderLine ->Items
User(user_id, user_name, app_version)
Order(order_id, order_details, user_id, app_version)
OrderLine(order_line_id, order_line_details, order_id, app_version)
Items(item_id, item_details, app_version)
Basically when i start the app_version is say "1.0" and order system proceeds as usual. At any point of time let us say i freeze the entire application to take statistics data. So what i do is i increment the app_version to 2.0. For this i make a copy of "entire data" all tables and put the app_version field to be 2.0. At the global application level i would have specified the app_version and the where clause should be applied for each and every query that is being fired.
Now here comes the problem. when i mark a new version, i want to make a copy of the existing data (forgetting the primary keys and saving them as new). Also if Order (app_version 1.0) refers an user say "User1" in app_version 1.0 then in the version 2.0 it must refer "User1" row in app_version 2.0.
I understand this is a complex requirement. However the size of the database will not be a problem because the total chunk of data will be of the order of 10mb with each table having 2000 rows at a maximum.
My Questions,
1) How can i take a graph of objects and say "Save it as if it where a new object but with app_version as 2.0". I took a look at calls like "replicate()" and "XML passivation of data". But they seem to be doing the job of transferring object across different data sources. I basically need a copy in the home database itself.
2) More importantly when i take a graph of data and save as new i dont want dangling references to old data. For example,
User (XYZ, appversion1) has orders (Order1, appversion1, XYZ) and (Order2, appversion1, XYZ)
when i copy the complete graph has to "intelligently update the references" and the result must be something like,
User (XYZ, appversion2) having orders (Order1, appversion2, XYZ) and(Order2, appversion2, XYZ)
and the old row also will reside in the same database.
Are there some solutions to this?
I *perfectly understand* that it will be quite complex and i might have to do lot of coding and testing. Essentially, i want some guidelines/how tos to start with.