Hi Brain,

use another SM implementation (e.g. SequenceManagerInMemoryImpl)
or implement your own SequenceManager.

HiLo-SM implementation use intern a new connection (because
we want to avoid 'rollback trouble'), thus your setting is made
on the wrong connection.

regards,
Armin

----- Original Message -----
From: "Brian Chaplin" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 03, 2003 8:17 PM
Subject: How do I customize insert for Sybase identity columns?


> I'm trying to handle sybase and SQL Server identity columns by
allowing OJB
> to control the sequence number generation through the
> SequenceManagerHighLowImpl.
>
> However, to do this I need to issue a "set identity_insert tablename
on"
> before the actual insert statement is executed?
>
> I did this in the afterInsert method of my BrokerAware persistence
object as
> follows:
>
> Connection conn = getConnection();
>
> stmt = conn.createStatement();
>
> stmt.execute("set identity_insert mcsp_test on");
>
> stmt.close();
>
>
>
> Although the set statment was executed successfully, when the
persistence
> broker issued the insert command, it still failed.
>
> afterInsert
>
> 1057255340516|0|1|statement||set identity_insert mcsp_test on
>
> 1057255340516|0|0|batch|INSERT INTO mcsp_test (id,col1) VALUES (?,?)
|INSERT
> INTO mcsp_test (id,col1) VALUES ('97','a13')
>
> 1057255340531|15|0|statement|INSERT INTO mcsp_test (id,col1) VALUES
(?,?)
> |INSERT INTO mcsp_test (id,col1) VALUES ('97','a13')
>
> [org.apache.ojb.broker.accesslayer.ConnectionManagerImpl] ERROR:
Commit on
> underlying connection failed, try to rollback
>
> JZ0BE: BatchUpdateException: Error occurred while executing batch
statement:
> Explicit value specified for identity field in table 'mcsp_test' when
> IDENTITY_INSERT is set to OFF.
>
>
>
>
>
> I'm not sure why.  Perhaps it was issued on another connection in my
pool
> but this still fails even for a singleton connection.
>
> Is there a way I can override how the persistence broker is
implementing the
> insert statement?
>
> Or is there a way I can customize the insert statement to issue a "set
> command"?
>
>
>
>
>
> ---------------------------------------------------------------------
> 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