db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arne.sie...@pta.de
Subject Antwort: AW: Disable Trigger in Torque?
Date Thu, 26 Aug 2004 13:45:58 GMT

Hi Ferruh,

you could patch the class org.apache.torque.adapter.DBOracle in your
project in the following way:

...
    public String getIDMethodType()
    {
        return AUTO_INCREMENT; /* was: SEQUENCE */
    }
...
    public String getIDMethodSQL(Object sequenceName)
    {
        return ("select " + sequenceName + ".currval from dual"); /* was:
".nextval from dual" */
    }

In combination with the setting

<database name="apdcat" defaultIdMethod="native">

this should result in your desired behaviour. But beware: tables without
that insert trigger will not work any longer with idmethod "native".

Regards
Arne



                                                                                         
                                                      
                      "Ferruh Zamangoer"                                                 
                                                      
                      <ferruh.zamangoer@gistec         An:      "Apache Torque Users List"
<torque-user@db.apache.org>                          
                      -online.de>                      Kopie:   <syg6@yahoo.com>,
(Blindkopie: Arne Siegel/PTA_GL/De)                           
                                                       Thema:   AW: Disable Trigger in Torque?
                                                 
                      26.08.2004 14:45                                                   
                                                      
                      Bitte antworten an                                                 
                                                      
                      "Apache Torque Users                                               
                                                      
                      List"                                                              
                                                      
                                                                                         
                                                      
                                                                                         
                                                      




Hi Bowen,

what I forgot to mentoined is that I don't use the sql-scripts which is
generated by Torque to create the DB. I've become from a customer a dump
file and want to insert and delete some data from this database. I have a
restricition that I can not edit or delete something in the database
settings, schema, triggers ....

I have the following settings:

database definition:
--------------------

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

table defintion:
----------------

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


In the databse the following trigger is defined, which is calle by any
insert:

Trigger definition:
-------------------

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;


When I disable the triggers in Oracle DB everything is working fine, but I
will not disable the triggers settings in the Database, I will disable it
in
Torrque?

(Thanks for any help)2

Regards
Ferruh





-----Ursprungliche Nachricht-----
Von: Robert Bowen [mailto:syg6@yahoo.com]
Gesendet: Donnerstag, 26. August 2004 14:14
An: Apache Torque Users List
Betreff: Re: Disable Trigger in Torque?


You need to set the defaultIdmethod for ALL of your
tables to native:

<database name="apdcat" defaultIdMethod="native">

... What Torque will then do is use the sequences
defined by the database. In order for this to work you
need to tell Torque the name of the sequence for every
table:

<table name="apd_acces" description="acces">
<id-method-parameter name="apd_acces_id_acces_seq"
value="apd_acces_id_acces_seq"/>

... This way Torque will call the sequence and assign
the new id correctly.

FYI, if you have a table with a non-auto-increment
primary key you must do the following:

<table name="apd_acces_perfil" idMethod="none"

... so Torque doesn't try to apply the "native" method
to this specific table ...

Cheers,
syg




--- Ferruh Zamangoer
<ferruh.zamangoer@gistec-online.de> wrote:

> Hi,
>
> does anybody know if it's possible to disable the
> trigger mechanism inside
> torque. My problem is that I have defined triggers
> in my Oracle database and
> when I'am inserting new Data, the ID(Primary Key)
> field is increment by
> Torque and by my trigger which I have defined. For
> Example the last value of
> my sequence is 134 but the db inserts 136.
>
> Thanks for any help.
>
> Regards
> Ferruh
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail:
> torque-user-help@db.apache.org
>
>




_______________________________
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.
http://promotions.yahoo.com/goldrush

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






**********************************************************************
http://www.pta.de
Mit 995 Erfahrungsberichten aus 35 Jahren erfolgreicher Projektarbeit!
**********************************************************************



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