XMLBeans
  1. XMLBeans
  2. XMLBEANS-473

XML "dateTime" type issue with JDBC Control

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: Version 2.2
    • Fix Version/s: None
    • Component/s: XmlObject
    • Labels:

      Description

      This issue happens when you define a database control method which SELECTs data and returns an XML Bean document. If one of the selected columns in your XML schema is of type "dateTime", then the XML text that is returned is missing the required "T" time separator character. Therefore, any subsequent attempts to call the getters on the resulting XML Bean document object (which normally should return java.util.Calendar objects) results in exceptions.

      @JdbcControl.SQL(statement="SELECT THE_ID as \"theId\", THE_DATE as \"theDate\" FROM JDBC_TEST WHERE THE_ID =

      {id}

      ")
      XJdbcTestDocument runJdbcTest(String id) throws SQLException;

      XJdbcTestDocument is generated from the below xml file
      =========================================
      <schema
      xmlns="http://www.w3.org/2001/XMLSchema"
      targetNamespace="java:///JdbcTestXMLSchema"
      xmlns:tns="http://www.example.org/JdbcTestXMLSchema"
      elementFormDefault="qualified">

      <element name="XJdbcTest">
      <complexType>
      <choice maxOccurs="unbounded">
      <element name="XJdbcTestRow">
      <complexType>
      <sequence>
      <element name="theId" type="string" minOccurs="0"/>
      <element name="theDate" type="dateTime" minOccurs="0" nillable="true"/>
      </sequence>
      </complexType>
      </element>
      </choice>
      </complexType>
      </element>
      </schema>
      =============================================
      The <xml-fragment>1998-05-31 00:00:00.0</xml-fragment> is missing "T" it should be <xml-fragment>1998-05-31T00:00:00.0</xml-fragment> when this is being returned by a JDB Control and getting below exception

      javax.el.ELException: org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException: Invalid date value: 1998-05-31 00:00:00.0
      at javax.el.BeanELResolver.getValue(BeanELResolver.java:266)
      at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:143)
      at com.sun.el.parser.AstValue.getValue(AstValue.java:118)
      at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192)
      at weblogic.servlet.jsp.ELHelper.evaluate(ELHelper.java:32)
      at jsp_servlet._jdbcresults._jspService(_jdbcresults.java:205)

      I think When JDBC Control maps result set to XML, it by default uses SQL object's toString() method to convert from SQL object to String.

      To override/customize this behavior we can use ResultSetMapper
      http://beehive.apache.org/docs/1.0.1/system-controls/jdbc/apidocs/javadoc/org/apache/beehive/controls/system/jdbc/ResultSetMapper.html
      but this requires some good amount change in the code.

      Can you please advise whether if there is any other alternative?

        Activity

        Sunil Polineni created issue -
        Sunil Polineni made changes -
        Field Original Value New Value
        Attachment jdbcTestWorkspace.rar [ 12513507 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Sunil Polineni
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development