I have a web application that has many tables (each represents a POJO). I wrote mapping files for each class, and then used Hibernate SchemaExportto generate tables in my database. Now I want to create 2 additional tables for each table created:
- User permissions table - saves user rights for POJOs, specific to each field,
each column represents a field in a POJO, each row represents a user, each cell will have a value of "read", "write", etc., representing the user's permission in the field .
- Data data table - saves the entire data history with a version number,
this table will have all the columns that are in the POJO table, and with 4 additional fields: the version of the data object, the transaction GUID (primary key), the datastores and the user completed this transaction.
I would like to have access to these tables through Hibernate after they are created. So that I can easily add / delete / update entries in them.
My question
Most columns in the secondary tables will be the same as the POJO table. Therefore, I think it’s better to somehow refer to the POJO table instead of creating new tables. Thus, if a new field is added to the POJO table, these tables will automatically change. But I don't seem to know how to do this. I thought maybe there is a way:
- hibernate, - POJO
, POJOPermission.hbm.xml, - , , POJO, .
- Java Hibernate
, java.lang.Class, POJO, , - - Hibernate
-, , , - ? , ...
!!!
[ - ]
XSLT hbm.xml , .. hibernate.cfg.xml . schemaexport, java ...