Details

    • Type: Sub-task Sub-task
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0-M2
    • Fix Version/s: 2.0.0-M3
    • Component/s: validation
    • Labels:
      None

      Description

      Per the JPA 2.0 specification, a TraversableResolver must be provided in order to meet the validation criteria outlined in section 3.6.1.2 of the 3/13/09 draft.

      The validator instance that is used for automatic validation upon lifecycle events must use a TraversableResolver
      that has the following behavior:
      • Attributes that have not been loaded must not be loaded.
      • Entity associations (single-valued or multi-valued) must not be traversed.

      These requirements guarantee that no unloaded attribute or association will be loaded by side effect and
      that no entity will be validated more than once.
      Embeddable attributes must be validated only if the Valid annotation has been specified on them.
      It is the responsibility of the persistence provider to pass an instance implementing the javax.validation.
      TraversableResolver interface to the Bean Validation provider by calling ValidatorFactory.
      usingContext().traversableResolver(

      1. test_patch.txt
        16 kB
        Dianne Richards

        Activity

        Hide
        Donald Woods added a comment -

        Rev799491 implements a TraversableResolverImpl that behaves identical to the default JPA aware one that BV providers must implement, so not sure why we have to provide this yet.... But, it's hooked into the ValidatorImpl code, as required by the spec.

        There is code commented out in the TRImpl that I would like to use, which would be more efficient than the default behavior of interrogating all providers, but it causes a java.lang.UnsupportedOperationException.

        Show
        Donald Woods added a comment - Rev799491 implements a TraversableResolverImpl that behaves identical to the default JPA aware one that BV providers must implement, so not sure why we have to provide this yet.... But, it's hooked into the ValidatorImpl code, as required by the spec. There is code commented out in the TRImpl that I would like to use, which would be more efficient than the default behavior of interrogating all providers, but it causes a java.lang.UnsupportedOperationException.
        Hide
        Donald Woods added a comment -

        Rev800568 - Updated TraversableResolver that calls only our OpenJPAPersistenceUtil. Updated OpenJPAPersistenceUtil.isLoaded() to handle UnsupportedOperationException when checking a detached entity and returns LoadState.UNKNOWN. Also added a testcase in TestPersistenceUtil to verify that caller gets isLoaded()==true for a detached entity and fixed a trace output in TestConstraints.

        Show
        Donald Woods added a comment - Rev800568 - Updated TraversableResolver that calls only our OpenJPAPersistenceUtil. Updated OpenJPAPersistenceUtil.isLoaded() to handle UnsupportedOperationException when checking a detached entity and returns LoadState.UNKNOWN. Also added a testcase in TestPersistenceUtil to verify that caller gets isLoaded()==true for a detached entity and fixed a trace output in TestConstraints.
        Hide
        Dianne Richards added a comment -

        Providing a patch containing some tests for this function.

        Show
        Dianne Richards added a comment - Providing a patch containing some tests for this function.
        Hide
        Donald Woods added a comment -

        Testcase patch applied to trunk as r908173

        Show
        Donald Woods added a comment - Testcase patch applied to trunk as r908173

          People

          • Assignee:
            Donald Woods
            Reporter:
            Jeremy Bauer
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Due:
              Created:
              Updated:
              Resolved:

              Development