How to implement CurrentUserProvider with no statically accessible context?

21 views
Skip to first unread message

chris ryan

unread,
Dec 14, 2022, 6:12:00 PM12/14/22
to Ebean ORM
Hello,

I'm currently using @SoftDelete and @History for a given model and realized the modified by / modified date is not being updated when deleting the model. That realization led me to the @WhoModified annotation, which needs me to implement CurrentUserProvider.

I'm currently using play framework which deprecated the ability to statically access requests. They changed to a design where the only way to access a request (and thus the current user) is by receiving it as an argument from inside a controller.

Is there another way about this? Like is there a delete method that accepts a string/username as the 'who modified'? 

Thanks,
Chris

Rob Bygrave

unread,
Jan 10, 2023, 2:53:41 AM1/10/23
to Ebean ORM
> Is there another way about this? Like is there a delete method that accepts a string/username as the 'who modified'?

Hmmm. Perhaps have a @Transient dummy property that you set the 'who' value to ... and use a BeanPersistAdapter preUpdate() or preSoftDelete() ... and in there set the dummy value to the column/property in question.

That might work.
Reply all
Reply to author
Forward
0 new messages