Hi guys.
Some time ago I started to develop a system to test and consolidate new knowledge. I am developing a simple system, but I'm still developing the database. I'm not a DBA, I am a Java developer, and am gaining knowledge in this field (databases).
Despite the system being developed to be simple, I have to take into account that it could be accessed by different applications, perhaps written in different languages from different people. Therefore, I believe that I should design the database to act defensively, so as to avoid data inconsistency.
During the development of the database, following these basic rules I saw the need to define a after select trigger in some tables. As I'm using PostgreSQL 9.5, I saw this was not possible, and that I had to do two things to get around this:
- Define a function that performs the select and make the necessary additional operations.
- Remove the select privilege so users only access the records by function.
This operation was necessary by the need to persist the total accesses made to present records in certain tables. In case, when selecting a record a field "accesses" is incremented in the selected record.
So far there is no problem. But when I start to think more forward in the application layer (Hibernate), I get confused. When removing the select privilege (or any other) from Hibernate, how Hibernate reads data from the database? More than that, I do not quite know what to do in this kind of situation.
In my confused head I wonder the following:
Should I set a read function? If so, how should it be? Can Hibernate read data and perform joins? Can I still use JPA Criteria API and/or JPQL? What are the Hibernate limitations about this? How should I work on this case? What would be the best or recommended approach?
I have searched on the internet, and also for help at stackoverflow (please, If you don't mind, take a look ):
http://stackoverflow.com/questions/3743 ... on-joiningUnfortunately, I had no return. I also have the
latest Hibernate book, and from what I researched, I could not find anything about it. Can anyone help me, please?
NOTE: I'm using Hibernate 5.1.0.