1 Reply Latest reply on Jan 10, 2008 8:20 AM by Pete Muir

    CascadeType.Remove and asynchronous method

    Andreas Franke Apprentice

      Hi,

      I have a entity that is in relation with some other entities with cascade type 'remove'.

      When I call an action from website to remove (entityManager.remove(userQuery);) an specific entity all other entities are also removed as expected.

      But if the same is called inside an asynchronous method only the first entity is removed(userQuery in this case).

      Here the quartz scheduled class

      @Name("processor")
      @AutoCreate
      public class ReportProcessor {
      
       @In
       EntityManager entityManager;
      
       @Logger Log log;
      
       @Asynchronous
       @Transactional
       public QuartzTriggerHandle scheduleDeleteReport(@Expiration Date when, UserQuery userQuery)
       {
       userQuery = entityManager.merge(userQuery);
      
       log.info("[#0] Processing userQuery #1", System.currentTimeMillis(), userQuery.getId());
      
       if (userQuery.getActive()) {
       entityManager.remove(userQuery);
       }
      
       return null;
       }
      }


      UserQuery for example is joined with
      @OneToMany(mappedBy="userQuery", cascade=CascadeType.REMOVE)



      Is there a solution get this working or what's the cause only the first entity is removed?