Is there any way to execute a JPQL (or native, I suppose) query without EntityManager?

I have a need to execute a JQPL (or native, that could work too but I’d rather use JPQL) query from my ExtLoginScreen but it seems EntityManager isn’t available from there - I get an exception whether I try injection or AppBeans.get().

Am I stuck or is there a way to do it without EntityManager?

Hi!

Did you try DataManager to do this? DataManager - CUBA Platform. Developer’s Manual

This is a DELETE query that I need to run; I don’t see a way DataManager can create/run those.

Well, another option - you can implement a service in the core module that uses EntityManager to execute DELETE statement and invoke this service in the screen controller.

True - I suppose. What I’m doing instead I think is I made the entity non-soft-delete (changed it to BaseUuidEntity) and I’ll just use dm.load() and dm.remove() to handle it.

In this case, you will disable soft delete for this table completely I believe. OK, changing the data model can do the job.

This is quite true, and appropriate and even desired in this case. This entity represents generated codes for 2FA and thus soft-delete isn’t desirable or needed anyway.