0 Replies Latest reply on Jan 26, 2010 4:09 PM by Beat Fluri

    Stack overflow problem while using @Restrict in conjuction with @PreUpdate and a PersistentPermissionResolver

    Beat Fluri Newbie

      We encounter a stack overflow error while using @PreUpdate and @Restrict in conjuction with a PersistenPermissionResolver. We use the Subversion trunk of Seam 2.2.0 GA and Hibernate.

      The stack overflow error occurs because of the following steps:

      1. @PreUpdate is triggered whenever entityManager.flush() is executed.

      2. While using a PersistentPermissionResolver, @Restrict of the with @PreUpdate-annotated method executes a select to lookup the permissions

      3. Since a select triggers a flush-event before executing the select statement, Step 1 is executed again, which leads to a StackOverflowError eventually.

      Until now, we worked with a workaround similar to:

      void preUpdate() {
          if (Identity.isSecurityEnabled() && Contexts.isSessionContextActive()) {
              EntityManager em = (EntityManager) Component.getInstance("entityManager");
              FlushModeType flushModeType = em.getFlushMode();
              try {
                  Identity.instance().checkPermission(this, "update");
              } finally {

      By using this workaround we prevent triggering the flush before the select statement.

      We can live with that workaround. However, @Restrict statements with EL are much more convenient than having the workaround spread all over our entities. In addition, the statements differ, which makes a entity-super-class inconvenient, too.

      So far, we did not find another solution, neither in this forum nor via google.

      Is there any solution to our problem? We appreciate any tips to solve this.

      Thanks for your help