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

Unique or primary key with the name --- not found in the table

Expand Messages
  • Rajiv Bhattacharya
    Hi, Thanks for helpin me out uptill now.i fixed the map file as Ron had said.I am now having some other problems with the map file. Given below is all the data
    Message 1 of 2 , Jul 29, 2005
    • 0 Attachment
      Hi,

      Thanks for helpin me out uptill now.i fixed the map file as Ron had
      said.I am now having some other problems with the map file.
      Given below is all the data
      -------------------------------------------------------------------------------------------
      COMMAND USED:-

      # java org.xmlmiddleware.xmldbms.tools.Transfer File1=xerces.props
      File2=db.props Method=StoreDocument MapFile=test.map XMLFile=test.xml
      ActionFile=test.act

      ------------------------------------------------------------------------------------------
      ERROR WHICH I AM GETTING:-

      org.xmlmiddleware.utils.XMLMiddlewareException: Unique or primary key
      with the name PINT_PRK not found in table "Default"."".""."PINT"
      at
      org.xmlmiddleware.xmldbms.maps.factories.MapCompiler.getUniqueKey(MapCompiler.java:2111)
      at
      org.xmlmiddleware.xmldbms.maps.factories.MapCompiler.resolveFKWrapper(MapCompiler.java:1870)
      at
      org.xmlmiddleware.xmldbms.maps.factories.MapCompiler.resolveFKWrappers(MapCompiler.java:1856)
      at
      org.xmlmiddleware.xmldbms.maps.factories.MapCompiler.endElement(MapCompiler.java:538)
      at
      org.apache.xerces.parsers.SAXParser.endElement(SAXParser.java:1403)
      at
      org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator.java:1550)
      at
      org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1149)
      at
      org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)
      at
      org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
      at
      org.xmlmiddleware.xmldbms.maps.factories.MapCompiler.compile(MapCompiler.java:225)
      at
      org.xmlmiddleware.xmldbms.tools.Transfer.createMap(Transfer.java:1509)
      at
      org.xmlmiddleware.xmldbms.tools.Transfer.storeDocumentInternal(Transfer.java:829)
      at
      org.xmlmiddleware.xmldbms.tools.Transfer.storeDocument(Transfer.java:479)
      at
      org.xmlmiddleware.xmldbms.tools.Transfer.dispatchStoreDocument(Transfer.java:696)
      at
      org.xmlmiddleware.xmldbms.tools.Transfer.dispatch(Transfer.java:434)
      at
      org.xmlmiddleware.xmldbms.tools.Transfer.main(Transfer.java:353)
      ------------------------------------------------------------------------------------------------

      DATABASE SCHEMA:-

      Two tables PINT and LINT

      I. PINT
      columns: PNAME_PHY,STATUS_PHY
      primary key: PNAME_PHY

      II. LINT
      columns: PNAME_PHY,LNAME_LOG,DESC_LOG,IP_LOG,ADDR_LOG
      primary key: LNAME_LOG
      foreign key: PNAME _PHY

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

      SQL STATEMENTS USED FOR CREATION OF TABLES:-(I copy pasted it from the
      JDBC code)

      stmt.execute( "create table pint ("+
      "pname_phy varchar(20),"+
      "status_phy varchar(20),"+
      "CONSTRAINT PINT_PRK PRIMARY KEY (pname_phy))"
      );


      stmt.execute("create table lint ("+
      "pname_phy varchar(20),"+
      "lname_log varchar(20),"+
      "desc_log varchar(20),"+
      "ip_log varchar(20),"+
      "addr_log varchar(20) ,"+
      "CONSTRAINT LINT_PRK PRIMARY KEY (lname_log),"+
      "CONSTRAINT LINT_FRK FOREIGN KEY (pname_phy) REFERENCES
      pint(pname_phy))"
      );

      ----------------------------------------------------------------------------------------
      THE XML FILE:-

      <info>
      <pint>
      <pname>P1</pname>
      <status>up</status>
      <lint>
      <lname>L1</lname>
      <desc>D1</desc>
      <traf>
      <ip>200</ip>
      </traf>
      <family>
      <int>
      <addr>192.19.13.15</addr>
      </int>
      </family>
      </lint>
      <lint>
      <lname>L2</lname>
      <desc>D2</desc>
      <traf>
      <ip>200</ip>
      </traf>
      <family>
      <int>
      <addr>10.19.13.15</addr>
      </int>
      </family>
      </lint>
      <lint>
      <lname>L3</lname>
      <desc>D3</desc>
      <family>
      <int>
      <addr>192.10.13.15</addr>
      </int>
      </family>
      </lint>
      </pint>
      <pint>
      <pname>P2</pname>
      <status>down</status>
      </pint>
      </info>

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

      THE MAP FILE:-

      <?xml version="1.0" ?>
      <!DOCTYPE XMLToDBMS SYSTEM
      "file:///home/project/rajiv/nex/mypjt/dtds/xmldbms2.dtd" >
      <XMLToDBMS Version="2.0" xmlns="http://www.xmlmiddleware.org/xmldbms/v2">
      <Databases>
      <Database Name="Default">
      <Catalog>
      <Schema>
      <Table Name="PINT">
      <Column Name="PNAME_PHY" DataType="VARCHAR"
      Length="20" Nullable="No"/>
      <Column Name="STATUS_PHY" DataType="VARCHAR"
      Length="20" Nullable="Yes"/>
      <PrimaryKey name="PINT_PRK">
      <UseColumn Name="PNAME_PHY"/>
      </PrimaryKey>
      </Table>
      <Table Name="LINT">
      <Column Name="PNAME_PHY" DataType="VARCHAR"
      Length="20" Nullable="No"/>
      <Column Name="LNAME_LOG" DataType="VARCHAR"
      Length="20" Nullable="No"/>
      <Column Name="DESC_LOG" DataType="VARCHAR"
      Length="20" Nullable="Yes" />
      <Column Name="IP_LOG" DataType="VARCHAR" Length="20"
      Nullable="Yes"/>
      <Column Name="ADDR_LOG" DataType="VARCHAR"
      Length="20" Nullable="Yes"/>
      <PrimaryKey Name="LINT_PRK">
      <UseColumn Name="LNAME_LOG"/>
      </PrimaryKey>
      <ForeignKey Name="LINT_FRK">
      <UseTable Name="PINT" />
      <UseUniqueKey Name="PINT_PRK" />
      <UseColumn Name="PNAME_PHY"/>
      </ForeignKey>
      </Table>
      </Schema>
      </Catalog>
      </Database>
      </Databases>
      <Maps>
      <ClassMap>
      <ElementType Name="pint"/>
      <ToClassTable Name="PINT"/>
      <PropertyMap>
      <ElementType Name="pname"/>
      <ToColumn Name="PNAME_PHY"/>
      </PropertyMap>
      <PropertyMap>
      <ElementType Name="status"/>
      <ToColumn Name="STATUS_PHY"/>
      </PropertyMap>
      <RelatedClass KeyInParentTable="Foreign">
      <ElementType Name="lint"/>
      <UseUniqueKey Name="LINT_PRK"/>
      <UseForeignKey Name="LINT_FRK"/>
      </RelatedClass>
      </ClassMap>
      <ClassMap>
      <ElementType Name="lint"/>
      <ToClassTable Name="LINT"/>
      <PropertyMap>
      <ElementType Name="lname"/>
      <ToColumn Name="LNAME_LOG"/>
      </PropertyMap>
      <PropertyMap>
      <ElementType Name="desc"/>
      <ToColumn Name="DESC_LOG"/>
      </PropertyMap>
      <InlineMap>
      <ElementType Name="traf" />
      <PropertyMap>
      <ElementType Name="ip"/>
      <ToColumn Name="IP_LOG"/>
      </PropertyMap>
      </InlineMap>
      <InlineMap>
      <ElementType Name="family" />
      <InlineMap>
      <ElementType Name="int" />
      <PropertyMap>
      <ElementType Name="addr"/>
      <ToColumn Name="ADDR_LOG"/>
      </PropertyMap>
      </InlineMap>
      </InlineMap>
      </ClassMap>
      </Maps>
      </XMLToDBMS>

      ----------------------------------------------------------------------------------------
      WHAT I THINK:-

      The mistake is most probably in the <RelatedClass>....</RelatedClass>
      or in the <Schema>..</Schema>.

      But i dont know what to do about it so my guess is pretty much useless:-(

      Q1.Is anything wrong in those areas?

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

      Q2. I cant understand how to deal with the name issue of the
      primary/unique key and foreign key?

      ATTEMPTS:
      AT1. tried naming them as their respective "coloumn names in the
      tables".But still got an error.
      ( i havent provided that mapfile with the post..)

      AT2. Then i dropped the tables and created new tables with CONSTRAINT
      names(the SQL statements are given above).I thought the names maybe
      referring to constraint names
      and so i changed the Map file.(This test.map file is provided with
      this post)

      RESULT:I still have the error as mentioned in the begining of the post.
      ----------------------------------------------------------------------------------------
      The mapping using names of unique/primary and foreign keys really
      confuses me.
      I am hoping someone could tell me where i am going wrong.
      Could you please give me some guidance

      Thanks,
      Rajiv

      Knowing that version 1 works pushes me to make Version 2 work too.:-)
    • Rajiv Bhattacharya
      hi, Its strange for me to reply to my post but I am doing it coz i fixed the error.The map file was the culprit.What i did was took separate printouts of the
      Message 2 of 2 , Jul 30, 2005
      • 0 Attachment
        hi,

        Its strange for me to reply to my post but I am doing it coz i fixed
        the error.The map file was the culprit.What i did was took separate
        printouts of the files order.xml and order.test which are present in
        the samples directory shipped with the download and then analysed the
        mapping .Then i used my analysis data to write the test.map file for
        my test.xml file.and voila the map file is fixed and everithing works.

        Moral of the story:-
        Good ol pen and paper can help you clear things things out.

        Ill be now moving on to some real huge files and see if i can work
        with them too.:-)

        -Rajiv



        --- In xml-dbms@yahoogroups.com, "Rajiv Bhattacharya"
        <racy_rajiv@y...> wrote:
        > Hi,
        >
        > Thanks for helpin me out uptill now.i fixed the map file as Ron had
        > said.I am now having some other problems with the map file.
        > Given below is all the data
        >
        -------------------------------------------------------------------------------------------
        > COMMAND USED:-
        >
        > # java org.xmlmiddleware.xmldbms.tools.Transfer File1=xerces.props
        > File2=db.props Method=StoreDocument MapFile=test.map XMLFile=test.xml
        > ActionFile=test.act
        >
        >
        ------------------------------------------------------------------------------------------
        > ERROR WHICH I AM GETTING:-
        >
        > org.xmlmiddleware.utils.XMLMiddlewareException: Unique or primary key
        > with the name PINT_PRK not found in table "Default"."".""."PINT"
        > at
        >
        org.xmlmiddleware.xmldbms.maps.factories.MapCompiler.getUniqueKey(MapCompiler.java:2111)
        > at
        >
        org.xmlmiddleware.xmldbms.maps.factories.MapCompiler.resolveFKWrapper(MapCompiler.java:1870)
        > at
        >
        org.xmlmiddleware.xmldbms.maps.factories.MapCompiler.resolveFKWrappers(MapCompiler.java:1856)
        > at
        >
        org.xmlmiddleware.xmldbms.maps.factories.MapCompiler.endElement(MapCompiler.java:538)
        > at
        > org.apache.xerces.parsers.SAXParser.endElement(SAXParser.java:1403)
        > at
        >
        org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator.java:1550)
        > at
        >
        org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1149)
        > at
        >
        org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)
        > at
        > org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
        > at
        >
        org.xmlmiddleware.xmldbms.maps.factories.MapCompiler.compile(MapCompiler.java:225)
        > at
        > org.xmlmiddleware.xmldbms.tools.Transfer.createMap(Transfer.java:1509)
        > at
        >
        org.xmlmiddleware.xmldbms.tools.Transfer.storeDocumentInternal(Transfer.java:829)
        > at
        >
        org.xmlmiddleware.xmldbms.tools.Transfer.storeDocument(Transfer.java:479)
        > at
        >
        org.xmlmiddleware.xmldbms.tools.Transfer.dispatchStoreDocument(Transfer.java:696)
        > at
        > org.xmlmiddleware.xmldbms.tools.Transfer.dispatch(Transfer.java:434)
        > at
        > org.xmlmiddleware.xmldbms.tools.Transfer.main(Transfer.java:353)
        >
        ------------------------------------------------------------------------------------------------
        >
        > DATABASE SCHEMA:-
        >
        > Two tables PINT and LINT
        >
        > I. PINT
        > columns: PNAME_PHY,STATUS_PHY
        > primary key: PNAME_PHY
        >
        > II. LINT
        > columns: PNAME_PHY,LNAME_LOG,DESC_LOG,IP_LOG,ADDR_LOG
        > primary key: LNAME_LOG
        > foreign key: PNAME _PHY
        >
        >
        ----------------------------------------------------------------------------------------
        >
        > SQL STATEMENTS USED FOR CREATION OF TABLES:-(I copy pasted it from the
        > JDBC code)
        >
        > stmt.execute( "create table pint ("+
        > "pname_phy varchar(20),"+
        > "status_phy varchar(20),"+
        > "CONSTRAINT PINT_PRK PRIMARY KEY (pname_phy))"
        > );
        >
        >
        > stmt.execute("create table lint ("+
        > "pname_phy varchar(20),"+
        > "lname_log varchar(20),"+
        > "desc_log varchar(20),"+
        > "ip_log varchar(20),"+
        > "addr_log varchar(20) ,"+
        > "CONSTRAINT LINT_PRK PRIMARY KEY (lname_log),"+
        > "CONSTRAINT LINT_FRK FOREIGN KEY (pname_phy) REFERENCES
        > pint(pname_phy))"
        > );
        >
        >
        ----------------------------------------------------------------------------------------
        > THE XML FILE:-
        >
        > <info>
        > <pint>
        > <pname>P1</pname>
        > <status>up</status>
        > <lint>
        > <lname>L1</lname>
        > <desc>D1</desc>
        > <traf>
        > <ip>200</ip>
        > </traf>
        > <family>
        > <int>
        > <addr>192.19.13.15</addr>
        > </int>
        > </family>
        > </lint>
        > <lint>
        > <lname>L2</lname>
        > <desc>D2</desc>
        > <traf>
        > <ip>200</ip>
        > </traf>
        > <family>
        > <int>
        > <addr>10.19.13.15</addr>
        > </int>
        > </family>
        > </lint>
        > <lint>
        > <lname>L3</lname>
        > <desc>D3</desc>
        > <family>
        > <int>
        > <addr>192.10.13.15</addr>
        > </int>
        > </family>
        > </lint>
        > </pint>
        > <pint>
        > <pname>P2</pname>
        > <status>down</status>
        > </pint>
        > </info>
        >
        >
        -------------------------------------------------------------------------------------
        >
        > THE MAP FILE:-
        >
        > <?xml version="1.0" ?>
        > <!DOCTYPE XMLToDBMS SYSTEM
        > "file:///home/project/rajiv/nex/mypjt/dtds/xmldbms2.dtd" >
        > <XMLToDBMS Version="2.0"
        xmlns="http://www.xmlmiddleware.org/xmldbms/v2">
        > <Databases>
        > <Database Name="Default">
        > <Catalog>
        > <Schema>
        > <Table Name="PINT">
        > <Column Name="PNAME_PHY" DataType="VARCHAR"
        > Length="20" Nullable="No"/>
        > <Column Name="STATUS_PHY" DataType="VARCHAR"
        > Length="20" Nullable="Yes"/>
        > <PrimaryKey name="PINT_PRK">
        > <UseColumn Name="PNAME_PHY"/>
        > </PrimaryKey>
        > </Table>
        > <Table Name="LINT">
        > <Column Name="PNAME_PHY" DataType="VARCHAR"
        > Length="20" Nullable="No"/>
        > <Column Name="LNAME_LOG" DataType="VARCHAR"
        > Length="20" Nullable="No"/>
        > <Column Name="DESC_LOG" DataType="VARCHAR"
        > Length="20" Nullable="Yes" />
        > <Column Name="IP_LOG" DataType="VARCHAR" Length="20"
        > Nullable="Yes"/>
        > <Column Name="ADDR_LOG" DataType="VARCHAR"
        > Length="20" Nullable="Yes"/>
        > <PrimaryKey Name="LINT_PRK">
        > <UseColumn Name="LNAME_LOG"/>
        > </PrimaryKey>
        > <ForeignKey Name="LINT_FRK">
        > <UseTable Name="PINT" />
        > <UseUniqueKey Name="PINT_PRK" />
        > <UseColumn Name="PNAME_PHY"/>
        > </ForeignKey>
        > </Table>
        > </Schema>
        > </Catalog>
        > </Database>
        > </Databases>
        > <Maps>
        > <ClassMap>
        > <ElementType Name="pint"/>
        > <ToClassTable Name="PINT"/>
        > <PropertyMap>
        > <ElementType Name="pname"/>
        > <ToColumn Name="PNAME_PHY"/>
        > </PropertyMap>
        > <PropertyMap>
        > <ElementType Name="status"/>
        > <ToColumn Name="STATUS_PHY"/>
        > </PropertyMap>
        > <RelatedClass KeyInParentTable="Foreign">
        > <ElementType Name="lint"/>
        > <UseUniqueKey Name="LINT_PRK"/>
        > <UseForeignKey Name="LINT_FRK"/>
        > </RelatedClass>
        > </ClassMap>
        > <ClassMap>
        > <ElementType Name="lint"/>
        > <ToClassTable Name="LINT"/>
        > <PropertyMap>
        > <ElementType Name="lname"/>
        > <ToColumn Name="LNAME_LOG"/>
        > </PropertyMap>
        > <PropertyMap>
        > <ElementType Name="desc"/>
        > <ToColumn Name="DESC_LOG"/>
        > </PropertyMap>
        > <InlineMap>
        > <ElementType Name="traf" />
        > <PropertyMap>
        > <ElementType Name="ip"/>
        > <ToColumn Name="IP_LOG"/>
        > </PropertyMap>
        > </InlineMap>
        > <InlineMap>
        > <ElementType Name="family" />
        > <InlineMap>
        > <ElementType Name="int" />
        > <PropertyMap>
        > <ElementType Name="addr"/>
        > <ToColumn Name="ADDR_LOG"/>
        > </PropertyMap>
        > </InlineMap>
        > </InlineMap>
        > </ClassMap>
        > </Maps>
        > </XMLToDBMS>
        >
        >
        ----------------------------------------------------------------------------------------
        > WHAT I THINK:-
        >
        > The mistake is most probably in the <RelatedClass>....</RelatedClass>
        > or in the <Schema>..</Schema>.
        >
        > But i dont know what to do about it so my guess is pretty much
        useless:-(
        >
        > Q1.Is anything wrong in those areas?
        >
        >
        --------------------------------------------------------------------------------------
        >
        > Q2. I cant understand how to deal with the name issue of the
        > primary/unique key and foreign key?
        >
        > ATTEMPTS:
        > AT1. tried naming them as their respective "coloumn names in the
        > tables".But still got an error.
        > ( i havent provided that mapfile with the post..)
        >
        > AT2. Then i dropped the tables and created new tables with CONSTRAINT
        > names(the SQL statements are given above).I thought the names maybe
        > referring to constraint names
        > and so i changed the Map file.(This test.map file is provided with
        > this post)
        >
        > RESULT:I still have the error as mentioned in the begining of the post.
        >
        ----------------------------------------------------------------------------------------
        > The mapping using names of unique/primary and foreign keys really
        > confuses me.
        > I am hoping someone could tell me where i am going wrong.
        > Could you please give me some guidance
        >
        > Thanks,
        > Rajiv
        >
        > Knowing that version 1 works pushes me to make Version 2 work too.:-)
      Your message has been successfully submitted and would be delivered to recipients shortly.