Basically I want DB2 to do the incrementation, therefor I try to get SequenceManagerNativeImpl running. I just discovered that I have misinterpreted the error message and that it doesn't relate to the autoincrement. Instead it looks like a java.util.Date conversion problem.

I turned on SQL statement debugging in OJB and that shows:
[org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl] DEBUG: SQL:INSERT INTO USER_TO_COURSE (created,status,status_msg,status_date,action) VALUES (?,?,?,?,?)


Then I launched my app in debug mode and found out that the exception is thrown in the setObjectForStatement method of the PlatformDefaultImpl when it tries to call ps.setObject(index, value, sqlType).
index = 1
value = (Date) Thu May 27 21:46:53 CEST 2004
sqlType = 93


So when the assigning the value for the created column in the preparedStatement the exception is thrown.

The created property of the action class looks like this:
private java.util.Date created = new java.util.Date();

The field mapping like this:
    <field-descriptor
        name="created"
        column="created"
        jdbc-type="TIMESTAMP"
        access="readwrite"
        nullable="false"
    >

The sql for the created column is:
CREATED TIMESTAMP NOT NULL WITH DEFAULT CURRENT TIMESTAMP

Any ideas what's wrong here? Is java.util.Date not supported by OJB?

Pedro Salgado wrote:
  Aren't you specifying on the SQL for the table to use a native sequence
manager implementation?

  It seems you are trying to use two sequence managers: one provided by OJB
(gets max and then incrementes on each insert) and one using the db native.

  Check http://db.apache.org/ojb/howto-use-db-sequences.html and
http://db.apache.org/ojb/sequencemanager.html

  or try using just
ID BIGINT NOT NULL
  and see what happens :)

Pedro Salgado

On 04/05/27 19:12, "Sebastian" <[EMAIL PROTECTED]> wrote:


Hi,

I'm trying to store objects (using PB) in a DB2 table where
autoincrement is defined for the id column and I don't get it working.

This is the SQL I used to create the table:
CREATE TABLE ACTION
(
ID BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1,
INCREMENT BY 1, NO CACHE),

... other fields ...

PRIMARY KEY (ID)
);

This is the OBJ Mapping I use for the object:
<field-descriptor
  name="id"
  column="id"
  jdbc-type="BIGINT"
  primarykey="true"
  nullable="false"
  access="readonly"
  autoincrement="true"

This is my class:
public class Action
{
private long id;

... other properties ...
}

When I use this sequence manager:
<sequence-manager className=
"org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl"/>
then I get:
SQL failure while insert object data for class Action, PK of the given
object is [ id=-2], object was [EMAIL PROTECTED], exception message is
[[IBM][JDBC Driver] CLI0613E  Program type out of range. SQLSTATE=S1003]

When I use this sequence manager:
<sequence-manager className=
"org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl">
<attribute attribute-name="autoNaming" attribute-value="true"/>
</sequence-manager>
then I get:
SQL failure while insert object data for class Action, PK of the given
object is [ id=22], object was [EMAIL PROTECTED], exception message is
[[IBM][JDBC Driver] CLI0613E  Program type out of range. SQLSTATE=S1003]

=> in this on every try the [ id=..] is incremented in the error message.

When I try to insert a record via SQL and do not specify the ID column
it works fine.

Any ideas or suggestions?

Thanks in advance,
Sebastian


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



Reply via email to