Wow, I'm so excited that I got here. This is the first project that is someway related to my task.
As far as I understand envers engine is used more for auditing stuff, but that would be great if you guys could share with me with your experience or thoughts regarding the situation below.
The situation is:
1. There is a huge complex domain model with different kind of inheritance types and relationships. Hiberate ORM framework is used.
2. There are two identical databases exist: local and global.
3. There is an application that allows registered users to make changes to data in local database.
4. Changes made to data in local database are visible to all users.
5. Once the logic part of changes is made the user synchronizes global database with local one.
The following scenario is to be implemented:
- the key point is to isolate users (the 4th point mentioned above), more precisely isolate "their workspaces", so changes made by user1 in local database are not visible for user2;
- also, user1 will synchronize the global database with his changes only (here there might be conflict situations, but that's not a big problem as a merge support can be implemented later).
I'm inclined to implement the solution transparent to existing application services. In easy words, all calls to hibernate session must be left untouched, but hibernate engine must perform magic stuff to access data considering the "current username".
I thought out a lot of different ways, but did not select the one so far.
Example solution (just flying hard brief thoughts): to create duplicate records in local database making them different from each other by an additional column "username". Further, to have hibernate to add a special condition (which depends on the "current username") into every where clause while it generates SQL statements.
Example solution 2: every user has his own database :-) This is the simplest try but it is good only for a finite small count of users.
The first second I visited this project I saw a dream where envers engine is integrated into hibernate and is made the illustrated scenario to be implemented easily.
Any comments are greatly appreciated.
Thank you for your time!