Hello everybody,
I try to find the best solution for a new implementation of a software and hope to find a way to do this with Hibernate. Maybe you can give me a hint how you would design this. Facts are as follows:
1. The Database (MySql) is already existent - so no (big) redesign is possible. 2. There is one scheme (actually PHPMyAdmin calls it databases which confuses me even more ;)) containing the base data. Lets asume we have names, adresses etc of Customers. Each Customer has its unique ID 3. There are N schemes containing the business data. Lets assume its information about the products the customers ordered. Each scheme contains alot of tables - but the structure of each table is the same in the different schemes. To split the data between different schemes is a need of datasecurity.
So - I want Hibernate to get me an object of one order (businessdata) and automatically fetch a customer object according to the customer-id stored in the data. So I have a relation between the two different schemes.
After a lot of searching I found that there is this "schema" attribute within the table-annotation that might be used in that kind of situation. Do I get this right?
But one problem remains - if i use this attribute I have to hardcode it in the sourcecode - so I need to code all objects (at least inherit em) for each of the N schemes... which seems to me a bit ugly because of the possibility to forget one entry (copy/paste error) and then overwriting data in the wrong scheme without ever recognizing. So - if this scheme-attribute is the solution for my problem - is it possible to set this dynamically so I can use only ONE SET OF CLASSES for the N schemes?
Thanks a lot!
Regards, Void
|