I have a class that implements PostUpdateEventListener, like this:
public class MyListener implements PostUpdateEventListener {
@Override
public void onPostUpdate(PostUpdateEvent event) {}
}
When I try something like the code below, the record is updated but my listener is not called:
getEntityManager().createQuery("update MyObject set myAttribute = null where idMyObject in (:ids)")
.setParameter("ids", idsList)
.executeUpdate();
getEntityManager().flush();
When I use the variant below, it got called:
myObject.setMyAttribute(null);
getEntityManager.merge(myObject);
getEntityManager.flush();
As I have a lot of objects to update, a bulk update makes sense, but I need to keep the listener call.
Any advice on how to achieve this?
Thank you!