createdBy and updatedBy UUID

Currently the createdBy and updatedBy fields in an entity save to the database as the username of the user.

Would it be possible to add the UUID of the user as well. This avoids are situation were filters for only the logged in user will fail if the username is edited.

One such scenario would be a woman who becomes married.

Debbie Smith might have a username of 'dsmith’
However her name changes to Debbie VonPuffenstuff
the user may want to change their login credentials to be changed to ‘dvonpuffenstuff’

Let me explain our position on this problem.

The createTs, createdBy, etc. attributes have been introduced for the purpose of easy human-readable auditing - you can just look at the database record and see who and when worked with it. We use createdBy in access constraint examples because it’s simple, clear and can be easily reproduced. However, in a real application I would recommend adding a separate userId attribute and use it for checking access - for the reason you have pointed out. Sorry for the possible confusion.

As for adding several more attributes to each entity by default - I think it would be an overkill.

1 Like

Thomas,

You could create your own MappedSuperclass with the fields you need; specify this mapped superclass as the parent class for your entities and, finally, using the mechanism of entity listeners fill up the fields with

userId

. It should do the trick.

Regards,

Aleksey

1 Like

Understandable. Thanks!