yes I use PB api.
that's not my problem.
if I work just with ojb everything work fine.
The problem is the following.
I delete a row directly on sql server (that has autocommit = true)with his
client;
then i try to insert a row with the same primary key with ojb.
Before doing so I do a select (with pb api) to look if the key already
exists.
Untlil here everything is good. 'Cause I retrieve a null (key does't exist).
when I do the store i catch the exception (from sql server) that says that
key already exists.
So ojb says that no such a key exists. sql server says that yes it exists.
Anyway I don't worry 'cause nobody should touch directly the database on
sql server, And if I keep inside application everything is good.
But I would like to know the reason. of corse should be better if I don't
have the problem.
thanks
On 6/20/05, Martin Kalén <[EMAIL PROTECTED]> wrote:
>
> Alessandro Colantoni wrote:
> > in repository_database.xml I have
> > <jdbc-connection-descriptor jcd-alias="default"
> default-connection="true"
> > platform="MsSQLServer" jdbc-level="2.0" driver="
> > com.microsoft.jdbc.sqlserver.SQLServerDriver" protocol="jdbc"
> > subprotocol="microsoft:sqlserver"
> > dbalias="//walqasrv01:1433;DatabaseName=trayectorias" username="steria"
> > password="filemon" eager-release="false" batch-mode="false"
> > useAutoCommit="2" ignoreAutoCommitExceptions="false">
> > In OJB.properties I have
> > ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCacheEmptyImpl
>
> You still didn't specify which OJB API you are using, is it PB API?
>
> Since you have set useAutoCommit="2" (explicit off) you will need
> to commit all transactions to the database before you can expect
> MS SQL to 'see' any deletes.
>
> If you are using PB API this might look something like:
>
> try {
> broker.beginTransaction();
>
> broker.store(obj);
> broker.delete(obj);
>
> broker.commitTransaction();
> } finally {
> if (broker.isInTransaction()) {
> broker.abortTransaction();
> }
> }
>
> Now if you store your object a second time, the deletion has been
> committed to the database and you should not get PK violations.
>
> See link [1] for more info about possible auto-commit settings
> in OJB.
>
> Regards,
> Martin
>
> [1] http://db.apache.org/ojb/docu/guides/repository.html#useAutoCommit
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>