I've created a sample application based on the JBoss Kitchensink example. This application records Entities using CDI Beans. I've found quite easy to store a new Entities using JPA + firing the Observer on the newly created Entity:
@Inject
private Event<MyEntity> propEventSrc;
public void put(MyEntity p){
em.persist(p);
propEventSrc.fire(p);
}
However I cannot find a way to fire the event in case the user wants to delete all records. In other words:
public void delete(){
Query query = em.createQuery("delete FROM MyEntity ");
query.executeUpdate();
// I need to fire an event here so that the List of MyEntities from the Producer class gets updated
}
I've tried with the notifyAll() method of the propEventSrc but that does just produce Exceptions, Any idea how to solve this issue ?
Thanks
Max