db-ojb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Kalén <mka...@apache.org>
Subject Re: primary key problem sql server
Date Mon, 20 Jun 2005 11:30:46 GMT
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: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Mime
View raw message