I have an additional data store with DB schema management disabled.
Each table has DATE_INSERT and DATE_UPDATE columns:
DATE_INSERT TIMESTAMP DEFAULT current_timestamp NOT NULL;
DATE_UPDATE TIMESTAMP;
DATE_UPDATE value updates by AFTER UPDATE trigger.
There is no CREATED_BY and UPDATED_BY columns so I can’t implement Creatable and Updatable interfaces.
If I left DATE_INSERT empty on creating new entity then I have exception that column value is null.
If I left DATE_UPDATE empty on editing existing entity then I need to press “Refresh” button to see its value in entity browser view.
I can create PrePersist and PreUpdate Entity Lifecycle Callbacks for every entity:
@PrePersist
public void prePersist() {
if (dateInsert == null) { dateInsert = new Date(); }
}
@PreUpdate
public void preUpdate() {
dateUpdate = new Date();
}
If these columns are always filled in the database (default column value, by trigger), you need to mark them with the parameters below, so that ORM doesn’t try to insert null value or update the value:
@Column(insertable = false, updatable = false)
Second, if you see that new value isn’t updated in the browser table after the editor screen is closed, you need to trigger the update of the just created/edited entity one more time manually in the browser.
To do that you need to generate the afterCommitHandler for create/edit actions.
For example if my table contains Card entity, and the table is linked to data container cardsDc, then I can generate the following code: