Loading ...
Sorry, an error occurred while loading the content.
 

Re: [xml-dbms] Problems with Data Types

Expand Messages
  • Ronald Bourret
    Christian -- Thanks for sending me your files. I duplicated your problem here and found the problem. The version of Transfer in the alpha 3 release does not
    Message 1 of 4 , Jan 7, 2005
      Christian --

      Thanks for sending me your files. I duplicated your problem here and
      found the problem. The version of Transfer in the alpha 3 release does
      not call org.xmlmiddleware.xmldbms.maps.utils.MetadataInitializer, which
      is used to match result set columns to mapping information.

      To fix this, you need to make the changes to
      org.xmlmiddleware.xmldbms.tools.Transfer listed below. I've tested these
      only enough to know that they fix the case you sent me. Let me know if
      any other problems arise.

      Thanks,

      -- Ron

      CHANGES TO TRANSFER
      -------------------

      1) Add the following import:

      import org.xmlmiddleware.xmldbms.maps.utils.*;

      2) Modify the method private Document
      retrieveDocumentInternal(Properties configProps, String mapFilename,
      Properties selects, String filterFilename, Hashtable params) so that it
      calls initTableMetadata:

      private Document retrieveDocumentInternal(Properties configProps,
      String mapFilename, Properties selects, String filterFilename, Hashtable
      params)
      throws XMLMiddlewareException, SQLException
      {
      ...
      resultSets = createResultSets(selects);
      transferInfo = createTransferInfo(map);
      filterSet = createFilterSet(map, filterFilename,
      (validate.indexOf(XMLDBMSProps.FILTERTOKEN) != -1));

      // New line of code:
      initTableMetadata(map, resultSets, filterSet);

      // Configure the DBMSToDOM object
      ...
      }

      3) Add the following method:

      private void initTableMetadata(XMLDBMSMap map, Hashtable resultSets,
      FilterSet filterSet)
      throws XMLMiddlewareException
      {
      MetadataInitializer initializer;
      Vector filters;
      Object o;
      ResultSetFilter rsFilter;
      String rsName;
      ResultSet rs;
      Table table;

      // Get a new MetadataInitializer.

      initializer = new MetadataInitializer(map);

      // Get the Vector of RootFilters and ResultSetFilters. Loop
      through the
      // filters and, for each ResultSetFilter that is found, use the
      result set
      // metadata to initialize the corresponding table metadata. Note that
      // ResultSetFilters associate result set names with table names.

      filters = filterSet.getFilters();
      for (int i = 0; i < filters.size(); i++)
      {
      // Get the next object and process it if it is a ResultSetFilter.

      o = filters.elementAt(i);
      if (o instanceof ResultSetFilter)
      {
      rsFilter = (ResultSetFilter)o;

      // Get the name of the result set specified in the filter and
      // get the corresponding ResultSet object.

      rsName = rsFilter.getResultSetName();
      rs = (ResultSet)resultSets.get(rsName);
      if (rs == null)
      throw new XMLMiddlewareException("Filter document
      specifies a result set with the name " + rsName + ". No result set with
      this name was specified in the properties passed to Transfer.");

      // Get the name of the table specified in the filter; this
      is the
      // name of the table in the map that maps the result set.
      Get the
      // corresponding Table object.

      table = map.getTable(rsFilter.getDatabaseName(),
      rsFilter.getCatalogName(),
      rsFilter.getSchemaName(),
      rsFilter.getTableName());
      if (table == null)
      throw new XMLMiddlewareException("Table specified in
      filter document but not found in map: " +
      Table.getUniversalName(rsFilter.getDatabaseName(),
      rsFilter.getCatalogName(), rsFilter.getSchemaName(),
      rsFilter.getTableName()));

      // Initialize the metadata for the columns in the table from
      // the result set metadata.

      initializer.initializeMetadata(table, rs);
      }
      }
      }



      Ronald Bourret wrote:

      > Hello!
      >
      > I hope your holidays were good. Back to business now...
      >
      > You are probably correct that the order of columns is getting switched
      > around and that this is causing the problem. What confuses me is that
      > this problem usually happens when calling DBMSToDOM directly (see [1]),
      > not when using Transfer.
      >
      > Could you please either post your complete map, filter, and commands
      > (.props files, command line, code used to call Transfer, etc.), or send
      > them to me directly? I will need to reproduce the problem here.
      >
      > Thanks,
      >
      > -- Ron
      >
      > [1] http://groups.yahoo.com/group/xml-dbms/message/3530
      >
      > Christian Dreier wrote:
      >
      >
      >>Hello!
      >>
      >>First of all I want to thank Ronald for his support!! As discussed in
      >>message 3625, I still have problems with Integer and Varchar data types.
      >>
      >>I'm using the following simple map with just one relation in the databse:
      >>
      >>
      >>
      >><Table Name="KUNDE">
      >>
      >> <Column Name="KUNDENNR" DataType="INTEGER" Nullable="No"/>
      >>
      >> <Column Name="NAME" DataType="VARCHAR" Length="50" Nullable="No"/>
      >>
      >> <Column Name="PLZ" DataType="VARCHAR" Length="50" Nullable="No"/>
      >>
      >> <Column Name="ORT" DataType="VARCHAR" Length="50" Nullable="Yes"/>
      >>
      >></Table>
      >>
      >>...
      >>
      >><ClassMap>
      >>
      >> <ElementType Name="Kunde"/>
      >>
      >> <ToClassTable Name="KUNDE"/>
      >>
      >> <PropertyMap>
      >>
      >> <Attribute Name="KundenNr"/>
      >>
      >> <ToColumn Name="KUNDENNR"/>
      >>
      >> </PropertyMap>
      >>
      >> <PropertyMap>
      >>
      >> <ElementType Name="Name"/>
      >>
      >> <ToColumn Name="NAME"/>
      >>
      >> </PropertyMap>
      >>
      >> <PropertyMap>
      >>
      >> <ElementType Name="PLZ"/>
      >>
      >> <ToColumn Name="PLZ"/>
      >>
      >> </PropertyMap>
      >>
      >> <PropertyMap>
      >>
      >> <ElementType Name="Ort"/>
      >>
      >> <ToColumn Name="ORT"/>
      >>
      >> </PropertyMap>
      >>
      >></ClassMap>
      >>
      >>
      >>
      >>The filter is simple as well:
      >>
      >>
      >>
      >><Filters>
      >>
      >> <Filter>
      >>
      >> <ResultSetInfo Table="KUNDE"/>
      >>
      >> </Filter>
      >>
      >></Filters>
      >>
      >>
      >>
      >>This is the corresponging select-statement: Select=SELECT KUNDENNR, NAME,
      >>PLZ, ORT FROM KUNDE
      >>
      >>
      >>
      >>When trying to publish the data using Transfer and RetrieveDocumentBySQL, I
      >>get the following errormessage: [XML-DBMS] conversion error: object must be
      >>a string
      >>
      >>
      >>
      >>When I leave out the KUNDENNR everywhere in the mapping and in the select
      >>statement, I get the following result:
      >>
      >>
      >>
      >><Bestellungen>
      >>
      >> <Kunde>
      >>
      >> <PLZ>9020</PLZ>
      >>
      >> <Ort>Anton</Ort>
      >>
      >> <Name>Klagenfurt</Name>
      >>
      >> </Kunde>
      >>
      >> <Kunde>
      >>
      >> <PLZ>9500</PLZ>
      >>
      >> <Ort>Berta</Ort>
      >>
      >> <Name>Villach</Name>
      >>
      >> </Kunde>
      >>
      >></Bestellungen>
      >>
      >>
      >>
      >>The problem here is that the values of Ort and Name are swapped, the output
      >>should look like follows:
      >>
      >>
      >>
      >><Bestellungen>
      >>
      >> <Kunde>
      >>
      >> <PLZ>9020</PLZ>
      >>
      >> <Ort>Klagenfurt </Ort>
      >>
      >> <Name>Anton</Name>
      >>
      >> </Kunde>
      >>
      >> <Kunde>
      >>
      >> <PLZ>9500</PLZ>
      >>
      >> <Ort>Villach </Ort>
      >>
      >> <Name>Berta</Name>
      >>
      >> </Kunde>
      >>
      >></Bestellungen>
      >>
      >>
      >>
      >>Than it looks like if the Datatype problem is due to this swapping problem,
      >>because XMLDBMS tries to put an Integer value in some String values...
      >>
      >>
      >>
      >>Could you tell me how to fix this problem?
      >>
      >>/Christian
      >
      >
      >
      >
      >
      >
      > To post a message, send it to: xml-dbms@yahoogroups.com
      > To unsubscribe, send a blank message to: xml-dbms-unsubscribe@yahoogroups.com
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      >
      >
      >
      >
    • Christian Dreier
      Hi Ron! I’ve done the changes and it’s working fine now. No more problems so far... Thank you very much! /Christian _____ Von: Ronald Bourret
      Message 2 of 4 , Jan 7, 2005
        Hi Ron! I’ve done the changes and it’s working fine now. No more problems so
        far...

        Thank you very much!

        /Christian



        _____

        Von: Ronald Bourret [mailto:rpbourret@...]
        Gesendet: Freitag, 07. Jänner 2005 09:22
        An: xml-dbms@yahoogroups.com
        Betreff: Re: [xml-dbms] Problems with Data Types



        Christian --

        Thanks for sending me your files. I duplicated your problem here and
        found the problem. The version of Transfer in the alpha 3 release does
        not call org.xmlmiddleware.xmldbms.maps.utils.MetadataInitializer, which
        is used to match result set columns to mapping information.

        To fix this, you need to make the changes to
        org.xmlmiddleware.xmldbms.tools.Transfer listed below. I've tested these
        only enough to know that they fix the case you sent me. Let me know if
        any other problems arise.

        Thanks,

        -- Ron

        CHANGES TO TRANSFER
        -------------------

        1) Add the following import:

        import org.xmlmiddleware.xmldbms.maps.utils.*;

        2) Modify the method private Document
        retrieveDocumentInternal(Properties configProps, String mapFilename,
        Properties selects, String filterFilename, Hashtable params) so that it
        calls initTableMetadata:

        private Document retrieveDocumentInternal(Properties configProps,
        String mapFilename, Properties selects, String filterFilename, Hashtable
        params)
        throws XMLMiddlewareException, SQLException
        {
        ...
        resultSets = createResultSets(selects);
        transferInfo = createTransferInfo(map);
        filterSet = createFilterSet(map, filterFilename,
        (validate.indexOf(XMLDBMSProps.FILTERTOKEN) != -1));

        // New line of code:
        initTableMetadata(map, resultSets, filterSet);

        // Configure the DBMSToDOM object
        ...
        }

        3) Add the following method:

        private void initTableMetadata(XMLDBMSMap map, Hashtable resultSets,
        FilterSet filterSet)
        throws XMLMiddlewareException
        {
        MetadataInitializer initializer;
        Vector filters;
        Object o;
        ResultSetFilter rsFilter;
        String rsName;
        ResultSet rs;
        Table table;

        // Get a new MetadataInitializer.

        initializer = new MetadataInitializer(map);

        // Get the Vector of RootFilters and ResultSetFilters. Loop
        through the
        // filters and, for each ResultSetFilter that is found, use the
        result set
        // metadata to initialize the corresponding table metadata. Note that
        // ResultSetFilters associate result set names with table names.

        filters = filterSet.getFilters();
        for (int i = 0; i < filters.size(); i++)
        {
        // Get the next object and process it if it is a ResultSetFilter.

        o = filters.elementAt(i);
        if (o instanceof ResultSetFilter)
        {
        rsFilter = (ResultSetFilter)o;

        // Get the name of the result set specified in the filter and
        // get the corresponding ResultSet object.

        rsName = rsFilter.getResultSetName();
        rs = (ResultSet)resultSets.get(rsName);
        if (rs == null)
        throw new XMLMiddlewareException("Filter document
        specifies a result set with the name " + rsName + ". No result set with
        this name was specified in the properties passed to Transfer.");

        // Get the name of the table specified in the filter; this
        is the
        // name of the table in the map that maps the result set.
        Get the
        // corresponding Table object.

        table = map.getTable(rsFilter.getDatabaseName(),
        rsFilter.getCatalogName(),
        rsFilter.getSchemaName(),
        rsFilter.getTableName());
        if (table == null)
        throw new XMLMiddlewareException("Table specified in
        filter document but not found in map: " +
        Table.getUniversalName(rsFilter.getDatabaseName(),
        rsFilter.getCatalogName(), rsFilter.getSchemaName(),
        rsFilter.getTableName()));

        // Initialize the metadata for the columns in the table from
        // the result set metadata.

        initializer.initializeMetadata(table, rs);
        }
        }
        }



        Ronald Bourret wrote:

        > Hello!
        >
        > I hope your holidays were good. Back to business now...
        >
        > You are probably correct that the order of columns is getting switched
        > around and that this is causing the problem. What confuses me is that
        > this problem usually happens when calling DBMSToDOM directly (see [1]),
        > not when using Transfer.
        >
        > Could you please either post your complete map, filter, and commands
        > (.props files, command line, code used to call Transfer, etc.), or send
        > them to me directly? I will need to reproduce the problem here.
        >
        > Thanks,
        >
        > -- Ron
        >
        > [1] http://groups.yahoo.com/group/xml-dbms/message/3530
        >
        > Christian Dreier wrote:
        >
        >
        >>Hello!
        >>
        >>First of all I want to thank Ronald for his support!! As discussed in
        >>message 3625, I still have problems with Integer and Varchar data types.
        >>
        >>I'm using the following simple map with just one relation in the databse:
        >>
        >>
        >>
        >><Table Name="KUNDE">
        >>
        >> <Column Name="KUNDENNR" DataType="INTEGER" Nullable="No"/>
        >>
        >> <Column Name="NAME" DataType="VARCHAR" Length="50" Nullable="No"/>
        >>
        >> <Column Name="PLZ" DataType="VARCHAR" Length="50" Nullable="No"/>
        >>
        >> <Column Name="ORT" DataType="VARCHAR" Length="50" Nullable="Yes"/>
        >>
        >></Table>
        >>
        >>...
        >>
        >><ClassMap>
        >>
        >> <ElementType Name="Kunde"/>
        >>
        >> <ToClassTable Name="KUNDE"/>
        >>
        >> <PropertyMap>
        >>
        >> <Attribute Name="KundenNr"/>
        >>
        >> <ToColumn Name="KUNDENNR"/>
        >>
        >> </PropertyMap>
        >>
        >> <PropertyMap>
        >>
        >> <ElementType Name="Name"/>
        >>
        >> <ToColumn Name="NAME"/>
        >>
        >> </PropertyMap>
        >>
        >> <PropertyMap>
        >>
        >> <ElementType Name="PLZ"/>
        >>
        >> <ToColumn Name="PLZ"/>
        >>
        >> </PropertyMap>
        >>
        >> <PropertyMap>
        >>
        >> <ElementType Name="Ort"/>
        >>
        >> <ToColumn Name="ORT"/>
        >>
        >> </PropertyMap>
        >>
        >></ClassMap>
        >>
        >>
        >>
        >>The filter is simple as well:
        >>
        >>
        >>
        >><Filters>
        >>
        >> <Filter>
        >>
        >> <ResultSetInfo Table="KUNDE"/>
        >>
        >> </Filter>
        >>
        >></Filters>
        >>
        >>
        >>
        >>This is the corresponging select-statement: Select=SELECT KUNDENNR, NAME,
        >>PLZ, ORT FROM KUNDE
        >>
        >>
        >>
        >>When trying to publish the data using Transfer and RetrieveDocumentBySQL,
        I
        >>get the following errormessage: [XML-DBMS] conversion error: object must
        be
        >>a string
        >>
        >>
        >>
        >>When I leave out the KUNDENNR everywhere in the mapping and in the select
        >>statement, I get the following result:
        >>
        >>
        >>
        >><Bestellungen>
        >>
        >> <Kunde>
        >>
        >> <PLZ>9020</PLZ>
        >>
        >> <Ort>Anton</Ort>
        >>
        >> <Name>Klagenfurt</Name>
        >>
        >> </Kunde>
        >>
        >> <Kunde>
        >>
        >> <PLZ>9500</PLZ>
        >>
        >> <Ort>Berta</Ort>
        >>
        >> <Name>Villach</Name>
        >>
        >> </Kunde>
        >>
        >></Bestellungen>
        >>
        >>
        >>
        >>The problem here is that the values of Ort and Name are swapped, the
        output
        >>should look like follows:
        >>
        >>
        >>
        >><Bestellungen>
        >>
        >> <Kunde>
        >>
        >> <PLZ>9020</PLZ>
        >>
        >> <Ort>Klagenfurt </Ort>
        >>
        >> <Name>Anton</Name>
        >>
        >> </Kunde>
        >>
        >> <Kunde>
        >>
        >> <PLZ>9500</PLZ>
        >>
        >> <Ort>Villach </Ort>
        >>
        >> <Name>Berta</Name>
        >>
        >> </Kunde>
        >>
        >></Bestellungen>
        >>
        >>
        >>
        >>Than it looks like if the Datatype problem is due to this swapping
        problem,
        >>because XMLDBMS tries to put an Integer value in some String values...
        >>
        >>
        >>
        >>Could you tell me how to fix this problem?
        >>
        >>/Christian
        >
        >
        >
        >
        >
        >
        > To post a message, send it to: xml-dbms@yahoogroups.com
        > To unsubscribe, send a blank message to:
        xml-dbms-unsubscribe@yahoogroups.com
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
        >
        >
        >
        >




        To post a message, send it to: xml-dbms@yahoogroups.com
        To unsubscribe, send a blank message to:
        xml-dbms-unsubscribe@yahoogroups.com




        _____

        Yahoo! Groups Links

        * To visit your group on the web, go to:
        http://groups.yahoo.com/group/xml-dbms/

        * To unsubscribe from this group, send an email to:
        xml-dbms-unsubscribe@yahoogroups.com
        <mailto:xml-dbms-unsubscribe@yahoogroups.com?subject=Unsubscribe>

        * Your use of Yahoo! Groups is subject to the Yahoo!
        <http://docs.yahoo.com/info/terms/> Terms of Service.



        [Non-text portions of this message have been removed]
      Your message has been successfully submitted and would be delivered to recipients shortly.