db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ferruh Zamangoer" <ferruh.zamang...@gistec-online.de>
Subject defaultIdMethod="none"
Date Tue, 31 Aug 2004 08:26:23 GMT
Hi,

can anybody tell me something more about the "none" option in the
defaultIdMethod. Few days ago I have posted my Problem with the triggers and
Tino Sperlich has wrote this message.

<cut>
HI,

so you cannot edit the database triggers and schemas,
but you can edit the torque schema.xml?

So you need to set in the schema.xml the defaultIdMethod="none" as
Robert Bowen pointed out.

This way torque will not try to create a primary key value from a
sequence but leave that all up to your code, e.g. your database trigger.

So change the schema, regenerate torque classes and than inserts etc.
will be processed without primary key generation from torque.

Regards,
Tino Sperlich
</cut>

I try the suggestion from Tino with the following Code:


JAVA CODE:
----------

AddressB322 ab322 = new AddressB322();
ab322.setAdminarea("FRA");
ab322.setCity("Frankfurt" +  System.currentTimeMillis());
ab322.setCountry("Hessen");
ab322.setPostcode("60313");
ab322.save();

System.out.println("TORQUE: " +  ab322.getIdaddress());

Database Settings in schema.xml:
--------------------------------
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE database SYSTEM
 "http://db.apache.org/torque/dtd/database_3_1.dtd">

<database
  name="ingeo"
  defaultIdMethod="none"
  skipSql="true">

<!-- #### TABLE ADDRESS_B322 ####-->

<table name="address_b322" description="Address_B322">
<column
  name="idaddress"
  required="true"
  primaryKey="true"
  type="INTEGER"
  size="5"
  description="ID Address"/>
<column
  name="city"
  required="false"
  type="VARCHAR"
  size="4000"
  description="City"/>
<column
  name="adminarea"
  required="false"
  type="VARCHAR"
  size="4000"
  description="Admin Area"/>
<column
  name="postcode"
  required="false"
  type="VARCHAR"
  size="4000"
  description="Post Code"/>
<column
  name="country"
  required="false"
  type="VARCHAR"
  size="4000"
  description="Country"/>
<id-method-parameter name="ADDRESS_ID_SEQ" value="ADDRESS_ID_SEQ"/>
</table>
</database>

sequence:
--------------
ADDRESS_ID_SEQ

Trigger for this table:
------------------------
TRIGGER "ADVMIS".Address_BIns
BEFORE INSERT ON ADDRESS_B322
FOR EACH ROW
DECLARE
   nummer  NUMBER;
BEGIN
   SELECT Address_id_Seq.NEXTVAL INTO nummer  FROM sys.dual;
   :NEW.idAddress := nummer;
END;

output of the JAVA_CODE
-----------------------

System.out.println("TORQUE: " +  ab322.getIdaddress()); ==> 0 ???????

After my understanding, when I'am using the defaultIdMethod="none" the Id's
are not generated by Torque and the underlying Database particularly the
Trigger generates the ID ?????

Regards
Ferruh









---------------------------------------------------------------------
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