What is the better way to get list of audited entites?
It is possible to use REVCHANGES table and look up all audited entytoes from this table but I belive that this is not best solution.
Thanks,
Volodymyr
Given Hibernate's Configuration object, you can call AuditConfiguration.getFor(cfg), and then the EntitiesConfigurations object to check if an entity is audited or not.
Note though that this is not an official API.
Related
I have to use Orion (NGSI v2), and I have a question about the name of entityId of my context;
could I use a simple ID or URN (like NGSI-LD spec)?
What is the best practice?
Thanks a lot
From a NGSIv2 point of view, any entity ID that complies with the identifiers syntax restrictions is valid.
Having said this, in general the simpler entity ID, the better from an integration point of view. For instance, if you are persisting context data using Cygnus sink for PostgreSQL, note that PostGresSQL could use tables which name includes the entity ID (for instance, if the dm-by-entity-database-schema DM is used, see this reference).
Thus, better to use simple entity IDs than URN-like entity IDs, from my point of view.
I think it is better to use URIs for your entities, your path to Linked Data will be smoother. The problem with table names should be fixed by the data storage component for instance by calculating a hash of the URI and converting it to the proper alphabet supported by the database concerning table names ...
I'm new to Hibernate and I want to audit all changes made to a table, to get logged into its Audit table.
In other words, any INSERT, UPDATE, DELETE on TEST table must be inserted into the TEST_AUD table.
I read a few articles on using dynamic audit tables that are created, but I cannot use it. The audit table must not be automatically generated.
I did not get a satisfactory article or solution to implement auditing using entities and Hibernate in SpringBoot?
Can someone please suggest a good article or provide an example?
Thanks!
You should use hibernate envers: https://hibernate.org/orm/envers/
set hibernate.hbm2ddl.auto to create, create-drop or update
or use org.hibernate.tool.EnversSchemaGenerator
You can audit entity or properties. If you entity name is TEST, the TEST_AUD will be automatically created.
You can also follow this article https://www.baeldung.com/database-auditing-jpa for more informations.
I have a web application using J2EE + Spring and a MySQL database. I need one entity which will be read-only. I have one main table with products, and they are only to read. There should be no insertion of new records and no updates currently.
The entity class should only read data and pass the entities forward (other entities are tables like order, shipments etc.).
Is there any solution for this? Does anyone have the same issue? Thanks for the help.
If you don't change an object, it will never be updated.
If you are using EclipseLink you can use the #ReadOnly annotation to mark something as read-only.
Right now we don't delete entities, but set a flag to "inactive" in the table (and filter these entities out for normal operations). Someone pointed me to Hibernate Envers, but it looks a little bit like overkill to me. My questions are:
Can we use Envers to perform our mechanism (active/inactive flag)?
If not, can Envers store a copy of a deleted entity in an archive table, but don't do any versioning / auditing stuff?
Are there lightweight alternatives for this task?
You could use Envers here, by extending the audit listener and ignoring insert/update events, however I agree that's an overkill.
Simply using an active flag with a dedicated DAO method or writing a simple Hibernate event listener should be much better suited for this task.
I've been searchin around a lot for a way to create, or configure a specific index on a table from EF code first, but really can't find a thing. mapping fluent Api doesn't seem to expose any means to do this. What am I missing?
You can add index creation either to custom database intitializer as mentioned in linked answer or you can use code based migrations. Migrations provide support for index creation.