OpenJPA
  1. OpenJPA
  2. OPENJPA-2183

Query hint "openjpa.hint.RelaxParameterTypeChecking" is reported to be unsupported and is ignored

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.1.0, 2.1.1, 2.2.0
    • Fix Version/s: None
    • Component/s: jpa
    • Labels:
      None
    • Environment:
      Websphere 8.0.3, openjpa-2.1.2-SNAPSHOT-r422266:1227818
    • Patch Info:
      Patch Available

      Description

      Setting
      Query q = em.createQuery(qs);
      q.setHint("openjpa.hint.RelaxParameterTypeChecking", "true");
      results in
      Warn: "openjpa.hint.RelaxParameterTypeChecking" is not a supported query hint. May be you meant "openjpa.hint.ParameterMarkerInQuery"?

      I assume the reason is that the openjpa.hint.RelaxParameterTypeChecking hint is not supported by any ProductDerivation and thus being refused in org.apache.openjpa.persistence.HintHandler#record.

      1. OPENJPA-2183.patch
        0.7 kB
        Albert Lee
      2. OPENJPA-2183.WAS8.jar
        16 kB
        Albert Lee

        Issue Links

          Activity

          Peter Martinovic created issue -
          Peter Martinovic made changes -
          Field Original Value New Value
          Link This issue blocks OPENJPA-1889 [ OPENJPA-1889 ]
          Albert Lee made changes -
          Attachment OPENJPA-2183.patch [ 12525630 ]
          Hide
          Albert Lee added a comment -

          Attached a patch. Can you give this a try?

          Show
          Albert Lee added a comment - Attached a patch. Can you give this a try?
          Albert Lee made changes -
          Patch Info Patch Available [ 10042 ]
          Hide
          Peter Martinovic added a comment -

          Thank you! Unfortunately we are using the IBM variant of OpenJPA packed into WebSphere AS (as specified in the 'Environment' field) and cannot patch the OpenJPA code to test it/make use of it. If WS8 uses the PersistenceProductDerivation (I am not quite sure how do product derivations work) I think the patch would work.

          Show
          Peter Martinovic added a comment - Thank you! Unfortunately we are using the IBM variant of OpenJPA packed into WebSphere AS (as specified in the 'Environment' field) and cannot patch the OpenJPA code to test it/make use of it. If WS8 uses the PersistenceProductDerivation (I am not quite sure how do product derivations work) I think the patch would work.
          Hide
          Albert Lee added a comment -

          Here is a jar contains the related changes targeted for WAS 8.0.

          This part has not been changed since 12/2010 so it is saved to use.

          • Save a copy of $WAS_HOME/plugins/com.ibm.ws.jpa.jar.
          • Replace the content of OPENJPA-2183.WAS8.jar to $WAS_HOME/plugins/com.ibm.ws.jpa.jar. .
          • Make sure the META-INF/MANIFEST.MF is NOT changed.
          • Once replace, refresh the osgi cache by "osgiCfgInit -all" before restart the server.

          If test is positive, I'll commit to trunk.

          Albert Lee.

          Show
          Albert Lee added a comment - Here is a jar contains the related changes targeted for WAS 8.0. This part has not been changed since 12/2010 so it is saved to use. Save a copy of $WAS_HOME/plugins/com.ibm.ws.jpa.jar. Replace the content of OPENJPA-2183 .WAS8.jar to $WAS_HOME/plugins/com.ibm.ws.jpa.jar. . Make sure the META-INF/MANIFEST.MF is NOT changed. Once replace, refresh the osgi cache by "osgiCfgInit -all" before restart the server. If test is positive, I'll commit to trunk. Albert Lee.
          Albert Lee made changes -
          Attachment OPENJPA-2183.WAS8.jar [ 12525673 ]
          Hide
          Peter Martinovic added a comment -

          Thank you, I will test it as soon as possible.

          Show
          Peter Martinovic added a comment - Thank you, I will test it as soon as possible.
          Hide
          Peter Martinovic added a comment -

          Hello Albert. Your patch works, the hint is correctly set on the query. Thank you.

          -------------------

          a) Named parameters and Query.setParameter work fine!

          -------------------

          b) Inline string values (e.g. String whereCondition = "a.enumAttrib1 = '" + value + "'") do not work.

          There is "java.lang.ClassCastException: java.lang.String incompatible with java.lang.Enum". It is because QueryImpl at line 826 uses Class.isAssignableFrom for parameter type checking, I guess it should use its own method QueryImpl.assertValueAssignable, or similar, that respects the RelaxParameterTypeChecking hint.

          -------------------

          I would consider this task as resolved and suggest to reopen OPENJPA-1889 (if inline string values are supposed to be supported).

          Show
          Peter Martinovic added a comment - Hello Albert. Your patch works, the hint is correctly set on the query. Thank you. ------------------- a) Named parameters and Query.setParameter work fine! ------------------- b) Inline string values (e.g. String whereCondition = "a.enumAttrib1 = '" + value + "'") do not work. There is "java.lang.ClassCastException: java.lang.String incompatible with java.lang.Enum". It is because QueryImpl at line 826 uses Class.isAssignableFrom for parameter type checking, I guess it should use its own method QueryImpl.assertValueAssignable, or similar, that respects the RelaxParameterTypeChecking hint. ------------------- I would consider this task as resolved and suggest to reopen OPENJPA-1889 (if inline string values are supposed to be supported).
          Peter Martinovic made changes -
          Comment [ Hello Albert. Your patch works, the hint is correctly set on the query. Thank you.

          Now there is "java.lang.ClassCastException: java.lang.String incompatible with java.lang.Enum". It is because QueryImpl at line 826 uses Class.isAssignableFrom for parameter type checking, I guess it should use its own method QueryImpl.assertValueAssignable, or similar, that respects the RelaxParameterTypeChecking hint.

          I would consider this task as resolved and suggest to reopen OPENJPA-1889. ]
          Albert Lee committed 1347017 (1 file)
          Hide
          Albert Lee added a comment -

          I committed the patch to trunk. If you need to get an fix for WAS, you will need to go through the IBM service channel to obtain the official fixpack.

          BTW, can you paste the ClassCastException stack here for further investigation on this problem.

          Show
          Albert Lee added a comment - I committed the patch to trunk. If you need to get an fix for WAS, you will need to go through the IBM service channel to obtain the official fixpack. BTW, can you paste the ClassCastException stack here for further investigation on this problem.

            People

            • Assignee:
              Unassigned
              Reporter:
              Peter Martinovic
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:

                Development