db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Allgaier <allgai...@yahoo.com>
Subject Re: Primary key is set to the foreign key value
Date Fri, 04 Sep 2009 17:36:02 GMT
Change the table definition to this:

  <table name="Person_SSN" description="Person SSN" idMethod="none">

You are generating the PK value yourself, so you don't need Torque or Postgres to do it for
you.

Adam





----- Original Message ----
From: levko <lev.kozakov@yahoo.com>
To: torque-user@db.apache.org
Sent: Thursday, September 3, 2009 3:43:33 PM
Subject: Primary key is set to the foreign key value


I have very simple DB schema, where the 1st table (Person) has PK 'id' and
the 2nd table (Person_SSN) has FK 'person_id' referring to the 'id' field of
the 'Person' table. The 'Person_SSN' table has its own PK 'ssn':

<database name="test" defaultIdMethod="idbroker"> 
  <table name="Person" description="Person Data"> 
    <column name="ID" 
      javaName="PersonId"
      required="true" 
      primaryKey="true" 
      type="INTEGER" 
      description="Person ID"/> 
    <column name="FULL_NAME" 
      javaName="FullName"
      required="true" 
      type="VARCHAR" size="128" 
      description="Full Name"/> 
    <column name="EMAIL" 
      javaName="EMailAddress"
      required="true" 
      type="VARCHAR" size="128" 
      description="EMail Address"/> 
    <unique> 
      <unique-column name="EMAIL"/> 
    </unique> 
  </table> 
  <table name="Person_SSN" description="Person SSN">
    <column name="PERSON_ID"
      javaName="PersonId"
      required="true"
      type="INTEGER"
      description="Foreign key Person"/>
    <column name="SSN"
      required="true"
      primaryKey="true" 
      type="CHAR" size="9"
      description="SSN"/>
    <foreign-key foreignTable="Person" onDelete="cascade">
      <reference local="PERSON_ID" foreign="ID"/> 
    </foreign-key>
  </table>
</database>

When I create 'PersonSsn' object, I set SSN to '123456789', but the DB
record shows that  SSN value is the same as the PERSON_ID value. I use
Torque 3.3 and PostgreSQL 8.4.0.

Could you, please, help me to understand what's the problem here?
I've uploaded the source files. The test driver is in the lk.test.TestOM
class.

Thanks in advance for any idea,
-- Lev http://www.nabble.com/file/p25283761/Test.zip Test.zip 
-- 
View this message in context: http://www.nabble.com/Primary-key-is-set-to-the-foreign-key-value-tp25283761p25283761.html
Sent from the Apache DB - Torque Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


      

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message