[prev in list] [next in list] [prev in thread] [next in thread]
List: turbine-torque-dev
Subject: Using idmethod native with Interbase
From: Gert Märzendorfer <gert.maerzendorfer () gmx ! net>
Date: 2002-06-25 19:59:47
[Download RAW message or body]
I'm currently evaluating Torque 3.0b2 against an existing database running
under InterBase WI-V6.0.1.0 (JDBC driver InterClient 1.60.1). One k.o. criteria
is the usage of generators (equivalent to Oracle sequences). Unfortunately
inserting a new record results in an exception, if selected the "native" id
method:
org.apache.torque.TorqueException: IdGenerator for table 'TASK' is null
at org.apache.torque.util.BasePeer.doInsert(Unknown Source)
at substral.om.BaseTaskPeer.doInsert(BaseTaskPeer.java:192)
at substral.om.BaseTaskPeer.doInsert(BaseTaskPeer.java:490)
at substral.om.BaseTask.save(BaseTask.java:841)
at substral.om.BaseTask.save(BaseTask.java:806)
at substral.om.BaseTask.save(BaseTask.java:789)
at TestTorque.Insert.SimpleInsert(Insert.java:26)
at TestTorque.Insert.main(Insert.java:42)
SimpleInsert: IdGenerator for table 'TASK' is null
A look inside the generated source code shows that DatabaseMap.addIdGenerator
(String type, IdGenerator idGen) is called for the above table with
type="native" and idGen=null!?
Diving deeper into the source of Torque lead me to the following steps, which
will enable Torque using a native idbroker in connection with Interbase:
(1) Additional generation of setPrimaryKeyMethodInfo() statement in
<Table>MapBuilder.java files: tMap.setPrimaryKeyMethodInfo("<Table>");
(2) Modification to DBInterbase.java:
public String getIDMethodType()
{
return SEQUENCE; // replaces return NO_ID_METHOD;
}
public String getIDMethodSQL(Object obj)
{
return "select * from GET_"+ obj +"_ID";
}
(3) For each table, which is designed for usage of native id broker, the user
has to create a generator:
CREATE GENERATOR "<TABLE>_ID_GEN";
(4) Furthermore for each of the above tables a stored procedure has to be
created by the user. Called via "select * from get_<table>_id" it will return
the next id for <table>.
CREATE PROCEDURE "GET_TASK_ID" RETURNS ("AVALUE" INTEGER) AS
BEGIN
avalue = GEN_ID(TASK_ID_GEN,1);
suspend;
END
^
Precondition: Table has to contain a primary key composed of one single column
of Interbase type INTEGER.
Will there be a way to integrate this improvement into the next release of
Torque? I'm sure Interbase community will be grateful.
Gert
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic