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

Unique key problem

Expand Messages
  • tarbster
    Hi all, I m getting this error: 2007-01-16 15:57:50,978 ERROR [RequestProcessor-20] persistencelayer.DataRequestCompiler (DataRequestCompiler.java:211) - This
    Message 1 of 5 , Jan 17, 2007
    • 0 Attachment
      Hi all,

      I'm getting this error:

      "2007-01-16 15:57:50,978 ERROR [RequestProcessor-20]
      persistencelayer.DataRequestCompiler (DataRequestCompiler.java:211) -
      This method may only be called for foreign keys."

      It's a result of some changes I recently made to my map file, and I'm
      wondering if it's actually possible to do what I'm trying to do...
      xmldbms2.dtd seems to say that it is, but the error makes me uncertain.

      The situation I have is that there are three database tables
      (t1,t2,t3) that can all be the parent of the same child table (t4).
      The FK relationships are:

      t1.column_1 -> t4.column_1
      t2.column_1 -> t4.column_2
      t3.column_1 -> t4.column_3

      I've been able to set up the foreign key relationship in my Oracle DB,
      but I'm struggling with the map file. The thing that makes it
      different from the norm is that the columns in t1,t2 and t3 are NOT
      the primary keys for those tables... they're just regular columns.
      This being the case, I've added unique keys to the <Table> elements
      for the parent tables, like this:

      <UniqueKey Name="dsplu_u1">
      <UseColumn Name="SCHEMPINLIST"/>
      </UniqueKey>

      ...and I've added <RelatedClass> elements to their classmaps, like this:

      <RelatedClass KeyInParentTable="Unique">
      <ElementType Name="schemzone"/>
      <UseUniqueKey Name="dsplu_u1"/>
      <UseForeignKey Name="SCHEMZONEKEY_FK1"/>
      </RelatedClass>

      ...and I've added corresponding foreign keys to the child table, like
      this:

      <ForeignKey Name="SCHEMZONEKEY_FK1">
      <UseTable Name="DESIGNSHAREDPINLISTUSAGE"/>
      <UseUniqueKey Name="dsplu_u1"/>
      <UseColumn Name="SCHEMPINLIST"/>
      </ForeignKey>

      ...but I'm getting this error. Is it possible to achieve what I'm
      trying to achieve, and am I going about it the wrong way?

      TIA
      Nick
    • k mani
      Hi all I am Mani, Working as a software engineer, as well as I m doing PhD, Topic is XMLDatamangement. If any one give the suggetions and which topic is good
      Message 2 of 5 , Jan 17, 2007
      • 0 Attachment
        Hi all
        I am Mani, Working as a software engineer, as well as I'm doing PhD, Topic is XMLDatamangement. If any one give the suggetions and which topic is good for me.

        Thank U




        ____________________________________________________________________________________
        Do you Yahoo!?
        Everyone is raving about the all-new Yahoo! Mail beta.
        http://new.mail.yahoo.com

        [Non-text portions of this message have been removed]
      • Ronald Bourret
        Hello, I ve been trying to recreate your problem here and I realized I don t understand the structure of your map file. For example, are there three ClassMaps
        Message 3 of 5 , Jan 19, 2007
        • 0 Attachment
          Hello,

          I've been trying to recreate your problem here and I realized I don't
          understand the structure of your map file. For example, are there three
          ClassMaps for t1, t2, and t3, each of which points to the ClassMap for
          t4? Is there another ClassMap that points to t1, t2, t3? etc.

          Could you send me your map file privately, or post a simplified version
          to the list?

          Also, did this error occur when transferring data from the document to
          the database or from the database to the document? If going from the
          document to the database, what actions were you using (insert, soft
          insert, etc.)?

          It would also help if you could explain what kind of data you are using.
          This isn't strictly necessary, but helps me visualize what your database
          is modeling and therefore understand how everything fits together.

          By the way, I can't see anything wrong with what you've done so far.

          Thanks,

          -- Ron

          tarbster wrote:
          > Hi all,
          >
          > I'm getting this error:
          >
          > "2007-01-16 15:57:50,978 ERROR [RequestProcessor-20]
          > persistencelayer.DataRequestCompiler (DataRequestCompiler.java:211) -
          > This method may only be called for foreign keys."
          >
          > It's a result of some changes I recently made to my map file, and I'm
          > wondering if it's actually possible to do what I'm trying to do...
          > xmldbms2.dtd seems to say that it is, but the error makes me uncertain.
          >
          > The situation I have is that there are three database tables
          > (t1,t2,t3) that can all be the parent of the same child table (t4).
          > The FK relationships are:
          >
          > t1.column_1 -> t4.column_1
          > t2.column_1 -> t4.column_2
          > t3.column_1 -> t4.column_3
          >
          > I've been able to set up the foreign key relationship in my Oracle DB,
          > but I'm struggling with the map file. The thing that makes it
          > different from the norm is that the columns in t1,t2 and t3 are NOT
          > the primary keys for those tables... they're just regular columns.
          > This being the case, I've added unique keys to the <Table> elements
          > for the parent tables, like this:
          >
          > <UniqueKey Name="dsplu_u1">
          > <UseColumn Name="SCHEMPINLIST"/>
          > </UniqueKey>
          >
          > ...and I've added <RelatedClass> elements to their classmaps, like this:
          >
          > <RelatedClass KeyInParentTable="Unique">
          > <ElementType Name="schemzone"/>
          > <UseUniqueKey Name="dsplu_u1"/>
          > <UseForeignKey Name="SCHEMZONEKEY_FK1"/>
          > </RelatedClass>
          >
          > ...and I've added corresponding foreign keys to the child table, like
          > this:
          >
          > <ForeignKey Name="SCHEMZONEKEY_FK1">
          > <UseTable Name="DESIGNSHAREDPINLISTUSAGE"/>
          > <UseUniqueKey Name="dsplu_u1"/>
          > <UseColumn Name="SCHEMPINLIST"/>
          > </ForeignKey>
          >
          > ...but I'm getting this error. Is it possible to achieve what I'm
          > trying to achieve, and am I going about it the wrong way?
          >
          > TIA
          > Nick
        • tarbster
          Thanks Ron, As I was in a bit of a hurry, I ended up refactoring some of the database tables so that I could use primary / foreign keys in the normal way. I
          Message 4 of 5 , Jan 23, 2007
          • 0 Attachment
            Thanks Ron,

            As I was in a bit of a hurry, I ended up refactoring some of the
            database tables so that I could use primary / foreign keys in the
            normal way. I didn't keep a copy of my original set of map file
            changes, so my memory of things-as-they-were is a little hazy! What it
            boiled down to (forgetting the "multiple parents" issue, which was
            really a side issue) is that I originally set out to model a
            parent-child relationship in the map file, using <ForeignKey> and
            <RelatedClass> but I ran into problems because the column in the
            parent table that was used as the foreign key wasn't the primary key
            in the parent table. To get around this, I tried specifying it as a
            <UniqueKey> but having done that, I got the error message that I reported.

            So in a nutshell... what I was unable to do was to define a FK
            relationship between two elements / tables where the column in the
            parent table used for the join was not the PK.

            To answer your question about what was happening at the time I got the
            error... I'm not a Java guy, but a colleague tells me that it was
            during our initialisation phase, where the map files are read and we
            are trying to create the "map objects", the in-memory version of the
            map files. Hope that makes sense...

            Regards,
            Nick


            --- In xml-dbms@yahoogroups.com, Ronald Bourret <rpbourret@...> wrote:
            >
            > Hello,
            >
            > I've been trying to recreate your problem here and I realized I don't
            > understand the structure of your map file. For example, are there three
            > ClassMaps for t1, t2, and t3, each of which points to the ClassMap for
            > t4? Is there another ClassMap that points to t1, t2, t3? etc.
            >
            > Could you send me your map file privately, or post a simplified version
            > to the list?
            >
            > Also, did this error occur when transferring data from the document to
            > the database or from the database to the document? If going from the
            > document to the database, what actions were you using (insert, soft
            > insert, etc.)?
            >
            > It would also help if you could explain what kind of data you are
            using.
            > This isn't strictly necessary, but helps me visualize what your
            database
            > is modeling and therefore understand how everything fits together.
            >
            > By the way, I can't see anything wrong with what you've done so far.
            >
            > Thanks,
            >
            > -- Ron
          • Ronald Bourret
            Hello, I haven t gotten back sooner because you already had a work-around. I tried to duplicate this on my machine, but was not able to do so. In particular, I
            Message 5 of 5 , Jan 29, 2007
            • 0 Attachment
              Hello,

              I haven't gotten back sooner because you already had a work-around.

              I tried to duplicate this on my machine, but was not able to do so. In
              particular, I was able to construct a map that used unique keys instead
              of primary keys in RelatedClass elements.

              I then looked back at your original email and was not able to find
              anything blatantly wrong.

              I then checked the code. The error is coming from the xmldbms.maps.Key
              class. There are three different methods that return this error and all
              are called by the MapCompiler class. It's not clear which one is causing
              the error, as your stack trace doesn't show this.

              At this point, there's not much else I can do. If you do recreate this
              bug, please send me your map file and the full error stack so I can see
              if there is a problem in the map files or in the code.

              -- Ron

              tarbster wrote:
              > Thanks Ron,
              >
              > As I was in a bit of a hurry, I ended up refactoring some of the
              > database tables so that I could use primary / foreign keys in the
              > normal way. I didn't keep a copy of my original set of map file
              > changes, so my memory of things-as-they-were is a little hazy! What it
              > boiled down to (forgetting the "multiple parents" issue, which was
              > really a side issue) is that I originally set out to model a
              > parent-child relationship in the map file, using <ForeignKey> and
              > <RelatedClass> but I ran into problems because the column in the
              > parent table that was used as the foreign key wasn't the primary key
              > in the parent table. To get around this, I tried specifying it as a
              > <UniqueKey> but having done that, I got the error message that I reported.
              >
              > So in a nutshell... what I was unable to do was to define a FK
              > relationship between two elements / tables where the column in the
              > parent table used for the join was not the PK.
              >
              > To answer your question about what was happening at the time I got the
              > error... I'm not a Java guy, but a colleague tells me that it was
              > during our initialisation phase, where the map files are read and we
              > are trying to create the "map objects", the in-memory version of the
              > map files. Hope that makes sense...
              >
              > Regards,
              > Nick
            Your message has been successfully submitted and would be delivered to recipients shortly.