2 Replies Latest reply on Jul 13, 2007 11:15 AM by p2auljr

    @Rollback annotation for validation logic causing detached o

    p2auljr

      I have a stateful session bean that uses an extended persistent context and is annotated with @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED).

      In a transactional action method annotated with @TransactionAttribute(TransactionAttributeType.REQUIRED), I perform business level validation. If the validation fails, I rollback the transaction using Seam's @Rollback annotation.

      However, the EJB specs indicates that a rollback will cause all entities in the entitymanager to be become detached. This seems like overkill because then I need to merge back all the instances and allow the user to fix the validation errors.

      Are there any best practices with this? Should I only rely on using Hibernate validation with seam's s:validateAll tag?

      Thank you.

        • 1. Re: @Rollback annotation for validation logic causing detach
          christian.bauer

          What do you want to achive with NOT_SUPPORTED as a default? If you want to simply prevent flushing of the persistence context, a much better approach is a Seam-managed PC with FlushModeType.MANUAL. The EJB3 spec mixes these concerns together and ties flushing to transactions. This is a major issue with the spec that hopefully will be fixed in the next revision.

          • 2. Re: @Rollback annotation for validation logic causing detach
            p2auljr

            Yes, I want to prevent flushing of the persistence context. I will give Seam-managed PC a try.

            But this raises another question. I am leaning towards keeping all entities objects contained in sfsbs rather than outjecting them into the conversation scope. If the sfsb is passivated, will the entity be detached from the seam-managed PC?

            Thanks again.