db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sean Laurent <s...@neuronfarm.com>
Subject Re: Problem with Insert records to the database
Date Wed, 11 Feb 2004 23:53:25 GMT
Sorry to jump in here, but I have a couple of thoughts.

Check out section 9.11 "Sequence-Manipulation Functions" in the PostgreSQL 7.4 

First, PostgreSQL does use "currval" with two R's.

Second, Tim Regovich already raised this issue in December of 2002.

He proposed a patch, which doesn't seem to have made it in.  The Torque 3.1 
code for java/org/apache/torque/adapter/DBPostgres.java still uses currval, 
instead of nextval.  As Tim pointed out, currval() returns "the value most 
recently obtained by nextval for this sequence in the current session. (An 
error is reported if nextval has never been called for this sequence in this 

Notice the part in parenthesis.  For new sessions, nextval() will never have 
been called and thus currval() won't work.  

What can I do to help make certain this gets fixed?

-Sean Laurent

-----Original Message-----
Date: Mon, 09 Feb 2004 20:14:56 +0100
From: Sheng Guo <sheng@in.tum.de>
Subject: Problem with Insert records to the database
Content-Type: text/plain; charset=ISO-8859-1; format=flowed


I checked it again in the Torque.template file, and I really configured 
it to postgresql. (see below) And I have the same value for 
torque.database.XXX.adapter=postgresql in the Torque.properties file.

# -------------------------------------------------------------------
#  T O R Q U E  P R O P E R T I E S
# -------------------------------------------------------------------
# These are your database settings. Look in the
# org.apache.torque.pool.* packages for more information.
# The parameters to connect to the default database.  You MUST
# configure these properly.
# -------------------------------------------------------------------


Russell Simpkins wrote:

>That error would seem to suggest that your Torque is configured to use Oracle 
and not postgresql.  Postgresql uses curval('name') and nextval('name');
>I may be wrong, but you should double check your configuration.
>-----Original Message-----
From: Sheng Guo [mailto:sheng@in.tum.de]
>Sent: Monday, February 09, 2004 11:23 AM
>To: torque-dev@db.apache.org
>Subject: Problem with Insert records to the database
>I am doing a web application project with Turbine2.3+Velocity+Torque. As 
>a database I have PostgreSQL 7.2.  As I tried to insert the data, which 
>I collected from the web page, there was alway an exception:
>org.apache.torque.TorqueException: ERROR: cnt_test_seq.currval is not 
>yet defined in this session
>the cnt_test_seq was already defined in the database, but I don't have 
>the "currval" anywhere in the database. How can that happen?
>I followed the tutorial on the Torque site to write the code, but it 
>didn't work. I had the following code in my Java file:
>//name of the method, which did the insert
>public void doSavedata(RunData data, Context context) {
>   //collect data from the Velocity template
>   String name = data.getParameters().getString("name");
>   String beschreibung = data.getParameters().getString("beschreibung");
>   String identifikator = data.getParameters().getString("identifikator");
>   String gueltigkeit = data.getParameters().getString("gueltigkeit");
>   CNTTest ct = new CNTTest();  //The om class, which was generated by 
>    //set the attributes of the instance of CNTTest
>    Integer id = new Integer(2);
>   ct.setId(id);
>   ct.setName(name);
>   ct.setDescription(beschreibung);
>   ct.setAttributeType(identifikator);
>   Integer g = new Integer(5);
>   ct.setSortOrder(g);
>   //save in to the database.
>   try {
>     ct.save();
>     System.out.println("save ok");
>     context.put("status", "sucess");
>     System.out.println("context--sucess");
>   }
>   catch (Exception ex) {
>     String message = ex.toString();
>     System.out.println(message);
>     ex.printStackTrace();
>     context.put("status", "failed");
>     context.put("message", message);
>     System.out.println("context--failed");
>   }
>I am looking forward to hearing from your earliest reply!
>yours sincerely

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

View raw message