Hi Tino, I know Hennings posting, but the problem is that the option autoincrement is deprecated in torque-gen-3.1, I also know that the option is not removed from this package I can use it, but I do not prefer it because I don't know what can be occure in later version for example when autoincrement option is removed????
The second problem is when I use autoincrement I have the problem that Torque, for example in the sequence the last value is 29, Torque wants to insert 29 but the database sets 30 to the database and the references in AddressDelpoint and AddressEmailadd to IDADDRESS 29. But the IDADDRESS=29 does no exists in the database. Regards Ferruh -----Ursprüngliche Nachricht----- Von: Sperlich, Tino [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 31. August 2004 12:17 An: Apache Torque Users List Betreff: AW: defaultIdMethod="none" Hallo, after having a closer look at the sources and the api docs, Hennings posting is the right path to follow: defaultIdMethod="autoincrement" is exactly doing what you need: Upon insertion of a record it doesn't create a primary key value itself, but reads the value inserted for it from the db. so firstly you should check the value of ab322 after insert (better still to use ab322.save()), then you should debug into your ad.setAddressB322() code to see what and if the idaddress is mapped correctly from ab322.idaddress to ad.idaddress. Hope that helps, Tino -----Ursprüngliche Nachricht----- Von: Ferruh Zamangoer [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 31. August 2004 11:43 An: Apache Torque Users List Betreff: AW: defaultIdMethod="none" Sorry I have seen that the data is inserted into the AddressB322 table correctly, but how can I set the references to the table AddressDelpoint, AddressEmailadd. My understanding is that the data is inserted correctly by the underlying database, but the ab322 Object becomes no data back or have not the actual primaryKey??? AddressB322 ab322 = new AddressB322(); ab322.setAdminarea("FRA"); ab322.setCity("Frankfurt" + System.currentTimeMillis()); ab322.setCountry("Hessen"); ab322.setPostcode("60313"); AddressB322Peer.doInsert(ab322); AddressDelpoint ad = new AddressDelpoint(); ad.setAddressB322(ab322); //references //ad.setIdaddress(ab322.getIdaddress()); ad.setDelpoint("Frankfurt"); ad.save(); AddressEmailadd aed = new AddressEmailadd(); aed.setAddressB322(ab322); //references //aed.setIdaddress(ab322.getIdaddress()); aed.setEmailadd("[EMAIL PROTECTED]"); aed.save(); -----Ursprüngliche Nachricht----- Von: Ferruh Zamangoer [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 31. August 2004 10:26 An: Apache Torque Users List Betreff: defaultIdMethod="none" 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]