db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Monroe <Greg.Mon...@dukece.com>
Subject RE: Create Composite Primary key and inserting values,Apache Torque
Date Mon, 26 Jul 2010 13:24:55 GMT
Below is an example of the XML needed.  Note that if your two part keys 
are not going to be Unique, it's generally better to have a separate 
autoincrement id field.  There are lots of DB problems that come from
not being able to clearly find the record you are dealing with because
of duplicate keys. 
 
<table name="user_groups" idMethod="none">
  <column default="0" name="group_id" primaryKey="true" 
          required="true" type="INTEGER"/>
  <column default="0" name="user_id" primaryKey="true" 
          required="true" type="INTEGER"/>
 
More columns and index definitions.

  <unique name="i_user_groups_key">
    <unique-column name="group_id"/>
    <unique-column name="user_id"/>
  </unique>  
  <foreign-key foreignTable="users">
    <reference local="user_id" foreign="user_id" />
  </foreign-key>
  <foreign-key foreignTable="groups">
    <reference local="group_id" foreign="group_id" />
  </foreign-key>
</table>

> -----Original Message-----
> From: Thomas Fischer [mailto:fischer@seitenbau.net]
> Sent: Monday, July 26, 2010 3:25 AM
> To: Apache Torque Developers List
> Subject: RE: Create Composite Primary key and inserting values,Apache
> Torque
> 
> 
> > I am trying to create a table like BookAuthorMap which has two columns
> :-
> > BookId and AuthorId. These are my primary key in another table. I want
> to
> > insert my values in these column rather auto increment.
> > ...
> 
> You need to set the attribute idMethod to "none" in the table element.
> See
> http://db.apache.org/torque/releases/torque-
> 3.3/generator/database.dtd.txt
> or
> http://db.apache.org/torque/releases/torque-3.3/generator/schema-
> reference.html
> 
>    Thomas
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-dev-help@db.apache.org

DukeCE Privacy Statement:
Please be advised that this e-mail and any files transmitted with
it are confidential communication or may otherwise be privileged or
confidential and are intended solely for the individual or entity
to whom they are addressed. If you are not the intended recipient
you may not rely on the contents of this email or any attachments,
and we ask that you please not read, copy or retransmit this
communication, but reply to the sender and destroy the email, its
contents, and all copies thereof immediately. Any unauthorized
dissemination, distribution or copying of this communication is
strictly prohibited.

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


Mime
View raw message