You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Alessandro Colantoni <al...@gmail.com> on 2005/04/18 09:38:06 UTC

What are Transaction limits with autoupdate = true.?

Hi all!.
 In a mehod i have the following to store a vale object :
 try{ 
broker = ServiceLocator.getInstance().findBroker();
broker.beginTransaction();
broker.store(storeVO);
broker.commitTransaction();
 } catch (PersistenceBrokerException e) {
if (broker!=null) broker.abortTransaction();
} finally {
if (broker != null) broker.close();
}
 storeVO has collection references with autoupdate = true in repository.xml.
 When I execute the method if there are errors in collection store (for 
example some field of wrong type) I catch the PersistenceBrokerException but 
the storeVO object is stored as well. Rollback doesn't take place, as if 
storeVO and collection references were not in the same transaction. 
 I want that if there is an error storing an element of the collection 
reference all transaction abort so that nothing should be stored.
How have I to do?
 thanks in advance...

Re: What are Transaction limits with autoupdate = true.?

Posted by Alessandro Colantoni <al...@gmail.com>.
All right!!!!.
Now everything works fine!.
You've been very helpful as every time!

 On 4/21/05, Armin Waibel <ar...@apache.org> wrote: 
> 
> Alessandro Colantoni wrote:
> > The last question.
> > Do I leave
> >
> > ignoreAutoCommitExceptions="false"
> >
> 
> yep! Normally the default settings of OJB are sufficient for most
> beginning scenario. 'ignoreAutoCommitExceptions' was introduced to
> bypass problems with older driver (e.g. sun's odbc-jdbc bridge driver).
> 
> regards,
> Armin
> 
> > ?
> >
> >
> >
> > On 4/21/05, Alessandro Colantoni <al...@gmail.com> wrote:
> >
> >> I just do it and all problems disappeared.
> >>I was just checking documentation when I get your post, and the default 
> is
> >>"1".
> >>Thanks a lot.
> >> On 4/21/05, Martin Kalén <mk...@apache.org> wrote:
> >>
> >>>Martin Kalén wrote:
> >>>
> >>>>I think you should give the default useAutoCommit="2" a try since you
> >>>>were using explicit transaction handling in your code.
> >>>
> >>>(Argh! I am not scoring many points in this thread.)
> >>>
> >>>What I wrote above is wrong.
> >>>
> >>>The default value of auto-commit is "1" (explicit on),
> >>>but I still think that the most right for you would be "2" (explicit
> >>>off).
> >>>
> >>>Sorry for being so confusing...
> >>>
> >>>HTH,
> >>>Martin
> >>>
> >>>---------------------------------------------------------------------
> >>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >>>For additional commands, e-mail: ojb-user-help@db.apache.org
> >>>
> >>>
> >>
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
>

Re: What are Transaction limits with autoupdate = true.?

Posted by Armin Waibel <ar...@apache.org>.
Alessandro Colantoni wrote:
> The last question.
> Do I leave 
> 
> ignoreAutoCommitExceptions="false"
>

yep! Normally the default settings of OJB are sufficient for most 
beginning scenario. 'ignoreAutoCommitExceptions' was introduced to 
bypass problems with older driver (e.g. sun's odbc-jdbc bridge driver).

regards,
Armin


> ?
> 
>    
> 
>  On 4/21/05, Alessandro Colantoni <al...@gmail.com> wrote: 
> 
>> I just do it and all problems disappeared.
>>I was just checking documentation when I get your post, and the default is 
>>"1".
>>Thanks a lot.
>> On 4/21/05, Martin Kalén <mk...@apache.org> wrote: 
>>
>>>Martin Kalén wrote:
>>>
>>>>I think you should give the default useAutoCommit="2" a try since you 
>>>>were using explicit transaction handling in your code.
>>>
>>>(Argh! I am not scoring many points in this thread.)
>>>
>>>What I wrote above is wrong.
>>>
>>>The default value of auto-commit is "1" (explicit on), 
>>>but I still think that the most right for you would be "2" (explicit 
>>>off).
>>>
>>>Sorry for being so confusing...
>>>
>>>HTH,
>>>Martin
>>>
>>>--------------------------------------------------------------------- 
>>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>For additional commands, e-mail: ojb-user-help@db.apache.org 
>>>
>>>
>>
> 

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


Re: What are Transaction limits with autoupdate = true.?

Posted by Alessandro Colantoni <al...@gmail.com>.
The last question.
Do I leave 

ignoreAutoCommitExceptions="false"

?

   

 On 4/21/05, Alessandro Colantoni <al...@gmail.com> wrote: 
> 
>  I just do it and all problems disappeared.
> I was just checking documentation when I get your post, and the default is 
> "1".
> Thanks a lot.
>  On 4/21/05, Martin Kalén <mk...@apache.org> wrote: 
> > 
> > Martin Kalén wrote:
> > > I think you should give the default useAutoCommit="2" a try since you 
> > > were using explicit transaction handling in your code.
> > 
> > (Argh! I am not scoring many points in this thread.)
> > 
> > What I wrote above is wrong.
> > 
> > The default value of auto-commit is "1" (explicit on), 
> > but I still think that the most right for you would be "2" (explicit 
> > off).
> > 
> > Sorry for being so confusing...
> > 
> > HTH,
> > Martin
> > 
> > --------------------------------------------------------------------- 
> > To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: ojb-user-help@db.apache.org 
> > 
> > 
>

Re: What are Transaction limits with autoupdate = true.?

Posted by Alessandro Colantoni <al...@gmail.com>.
I just do it and all problems disappeared.
I was just checking documentation when I get your post, and the default is 
"1".
Thanks a lot.
 On 4/21/05, Martin Kalén <mk...@apache.org> wrote: 
> 
> Martin Kalén wrote:
> > I think you should give the default useAutoCommit="2" a try since you
> > were using explicit transaction handling in your code.
> 
> (Argh! I am not scoring many points in this thread.)
> 
> What I wrote above is wrong.
> 
> The default value of auto-commit is "1" (explicit on),
> but I still think that the most right for you would be "2" (explicit off).
> 
> Sorry for being so confusing...
> 
> HTH,
> Martin
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
>

Re: What are Transaction limits with autoupdate = true.?

Posted by Martin Kalén <mk...@apache.org>.
Martin Kalén wrote:
> I think you should give the default useAutoCommit="2" a try since you
> were using explicit transaction handling in your code.

(Argh! I am not scoring many points in this thread.)

What I wrote above is wrong.

The default value of auto-commit is "1" (explicit on),
but I still think that the most right for you would be "2" (explicit off).

Sorry for being so confusing...

HTH,
  Martin

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


Re: What are Transaction limits with autoupdate = true.?

Posted by Martin Kalén <mk...@apache.org>.
Alessandro Colantoni wrote:
> I'm using Microsoft sql server and not MySQL.

Sorry, I can't read. :-)

>  Happy to Know that is not an Ojb problem, so I have just to fix on my code.
> Martin Post has me make to think if I have to configure something in 
> repository-database.xml.
>  that's my jdbc-connection-descriptor :
>  
> <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
> ="0" ignoreAutoCommitExceptions="false">

I think you should give the default useAutoCommit="2" a try since you
were using explicit transaction handling in your code.

With mode 0 you are dependent on the auto-commit state from SQL Server,
which I would assume is default ON since your programmatic rollback
did not happen.

See also http://db.apache.org/ojb/docu/guides/repository.html#useAutoCommit

Regards,
  Martin

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


Re: What are Transaction limits with autoupdate = true.?

Posted by Alessandro Colantoni <al...@gmail.com>.
Hi !.
I'm using Microsoft sql server and not MySQL.
 Happy to Know that is not an Ojb problem, so I have just to fix on my code.
Martin Post has me make to think if I have to configure something in 
repository-database.xml.
 that's my jdbc-connection-descriptor :
 
<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
="0" ignoreAutoCommitExceptions="false">

<connection-pool maxActive="5" maxIdle="2" maxWait="3"minEvictableIdleTimeMillis
="4" numTestsPerEvictionRun="5" testOnBorrow="true"
testOnReturn="true"testWhileIdle
="true" timeBetweenEvictionRunsMillis="6" whenExhaustedAction="2"validationQuery
="select 1 from sysobjects" logAbandoned="true"
removeAbandoned="true"removeAbandonedTimeout
="8"/>

<sequence-manager className="
org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl">

<attribute attribute-name="autoNaming" attribute-value="false"/>

</sequence-manager>

</jdbc-connection-descriptor>
I send you the involved part of repository.xml too.
 
<class-descriptor class="com.steria.tc.vo.DiagnosticoVO" table="MDIAG">

<field-descriptor id="1" name="codigo" column="codigo"
jdbc-type="VARCHAR"primarykey
="true" autoincrement="false"/>

<field-descriptor id="3" name="descripcion" column="descripcion" jdbc-type="
VARCHAR"/>

<field-descriptor id="4" name="texto" column="texto" jdbc-type="VARCHAR"/>

<field-descriptor id="3" name="codmclas" column="codmclas" jdbc-type="
VARCHAR"/>

<field-descriptor id="4" name="fcrea" column="fcrea" jdbc-type="TIMESTAMP"/>

<field-descriptor id="5" name="usucrea" column="usucrea" jdbc-type="VARCHAR
"/>

<field-descriptor id="6" name="fmodif" column="fmodif" jdbc-type="TIMESTAMP
"/>

<field-descriptor id="7" name="usumodif" column="usumodif" jdbc-type="
VARCHAR"/>

<reference-descriptor name="claseVO"
class-ref="com.steria.tc.vo.ClaseVO"auto-retrieve
="false">

<foreignkey field-ref="codmclas"/>

</reference-descriptor>

<collection-descriptor name="diagInteVOs" element-class-ref="
com.steria.tc.vo.DiagInteVO" orderby="codinte" sort="ASC" auto-retrieve="
false" auto-update="true" auto-delete="object">

<inverse-foreignkey field-ref="coddiag"/>

</collection-descriptor>

<collection-descriptor name="diagObjeVOs" element-class-ref="
com.steria.tc.vo.DiagObjeVO" orderby="codobje" sort="ASC" auto-retrieve="
false" auto-update="true" auto-delete="object">

<inverse-foreignkey field-ref="coddiag"/>

</collection-descriptor>

<collection-descriptor name="diagCDefVOs" element-class-ref="
com.steria.tc.vo.DiagCDefVO" orderby="codcdef" sort="ASC" auto-retrieve="
false" auto-update="true" auto-delete="object">

<inverse-foreignkey field-ref="coddiag"/>

</collection-descriptor>

</class-descriptor>
When I execute my method I pass an instance of DiagnosticoVO.
it has populated the property diagInteVOs with a vector of insances of 
DiagInteVO.
One of them has a field too large. A row for DiagnosticoVO in insert as well
I cheked that it corretly go in the piece of code where it do begin 
transaction and in the piece of code where it do abort transaction.
 Could it be a configuration problem?
Thanks for help.
 
  
 On 4/20/05, Martin Kalén <mk...@apache.org> wrote: 
> 
> Alessandro Colantoni wrote:
> > Change are really written to the database.
> > I get an error of MsSQLServer.
> 
> Beware that MySQL using MYISAM storage in early versions [*]
> does not implement database transactions.
> 
> Either use InnoDB if your licensing requirements permit it or
> try to upgrade to a newer MySQL version.
> 
> Regards,
> Martin
> 
> [*] I believe this to be <4.x where x=something you would have to confirm
> in the MySQL docs...
> 
> P.S. Or better yet: Use PostgreSQL instead. It's also free but is a real 
> database. ;-)
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
>

Re: What are Transaction limits with autoupdate = true.?

Posted by Martin Kalén <mk...@apache.org>.
Alessandro Colantoni wrote:
> Change are really written to the database.
> I get an error of MsSQLServer.

Beware that MySQL using MYISAM storage in early versions [*]
does not implement database transactions.

Either use InnoDB if your licensing requirements permit it or
try to upgrade to a newer MySQL version.

Regards,
  Martin

[*] I believe this to be <4.x where x=something you would have to confirm
  in the MySQL docs...

P.S. Or better yet: Use PostgreSQL instead. It's also free but is a real database. ;-)


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


Re: What are Transaction limits with autoupdate = true.?

Posted by Armin Waibel <ar...@apache.org>.
Hi,

Alessandro Colantoni wrote:
> Hi 
> Change are really written to the database.
> I get an error of MsSQLServer.
> 

in this case I assume that the problem wasn't caused by OJB, because 
between PB.beginTransaction() and PB.commitTransaction() it's guaranteed 
that OJB use the same connection.
If you only do
 >>>broker.beginTransaction();
 >>>broker.store(storeVO);
 >>>broker.commitTransaction();
and an exception occur, all changes will be discarded on 
PB.abortTransaction.

Except you don't let OJB change the autoCommit state of the connection.
http://db.apache.org/ojb/docu/guides/repository.html#useAutoCommit

Are you sure that only one PB was used the perform your objects?

regards,
Armin

> 
>  On 4/19/05, Armin Waibel <ar...@apache.org> wrote: 
> 
>>Hi,
>>
>>are the changes really writen to database or is it a caching issue?
>>
>>regards,
>>Armin
>>
>>Alessandro Colantoni wrote:
>>
>>>Hi all!.
>>>In a mehod i have the following to store a vale object :
>>>try{
>>>broker = ServiceLocator.getInstance().findBroker();
>>>broker.beginTransaction();
>>>broker.store(storeVO);
>>>broker.commitTransaction();
>>>} catch (PersistenceBrokerException e) {
>>>if (broker!=null) broker.abortTransaction();
>>>} finally {
>>>if (broker != null) broker.close();
>>>}
>>>storeVO has collection references with autoupdate = true in 
>>
>>repository.xml.
>>
>>>When I execute the method if there are errors in collection store (for
>>>example some field of wrong type) I catch the PersistenceBrokerException 
>>
>>but
>>
>>>the storeVO object is stored as well. Rollback doesn't take place, as if
>>>storeVO and collection references were not in the same transaction.
>>>I want that if there is an error storing an element of the collection
>>>reference all transaction abort so that nothing should be stored.
>>>How have I to do?
>>>thanks in advance...
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
> 
> 

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


Re: What are Transaction limits with autoupdate = true.?

Posted by Alessandro Colantoni <al...@gmail.com>.
Hi 
Change are really written to the database.
I get an error of MsSQLServer.


 On 4/19/05, Armin Waibel <ar...@apache.org> wrote: 
> 
> Hi,
> 
> are the changes really writen to database or is it a caching issue?
> 
> regards,
> Armin
> 
> Alessandro Colantoni wrote:
> > Hi all!.
> > In a mehod i have the following to store a vale object :
> > try{
> > broker = ServiceLocator.getInstance().findBroker();
> > broker.beginTransaction();
> > broker.store(storeVO);
> > broker.commitTransaction();
> > } catch (PersistenceBrokerException e) {
> > if (broker!=null) broker.abortTransaction();
> > } finally {
> > if (broker != null) broker.close();
> > }
> > storeVO has collection references with autoupdate = true in 
> repository.xml.
> > When I execute the method if there are errors in collection store (for
> > example some field of wrong type) I catch the PersistenceBrokerException 
> but
> > the storeVO object is stored as well. Rollback doesn't take place, as if
> > storeVO and collection references were not in the same transaction.
> > I want that if there is an error storing an element of the collection
> > reference all transaction abort so that nothing should be stored.
> > How have I to do?
> > thanks in advance...
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
>

Re: What are Transaction limits with autoupdate = true.?

Posted by Armin Waibel <ar...@apache.org>.
Hi,

are the changes really writen to database or is it a caching issue?

regards,
Armin

Alessandro Colantoni wrote:
> Hi all!.
>  In a mehod i have the following to store a vale object :
>  try{ 
> broker = ServiceLocator.getInstance().findBroker();
> broker.beginTransaction();
> broker.store(storeVO);
> broker.commitTransaction();
>  } catch (PersistenceBrokerException e) {
> if (broker!=null) broker.abortTransaction();
> } finally {
> if (broker != null) broker.close();
> }
>  storeVO has collection references with autoupdate = true in repository.xml.
>  When I execute the method if there are errors in collection store (for 
> example some field of wrong type) I catch the PersistenceBrokerException but 
> the storeVO object is stored as well. Rollback doesn't take place, as if 
> storeVO and collection references were not in the same transaction. 
>  I want that if there is an error storing an element of the collection 
> reference all transaction abort so that nothing should be stored.
> How have I to do?
>  thanks in advance...
> 

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