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 kristian meier <kr...@jentro.com> on 2003/12/18 16:53:11 UTC

old thread: Re: ConnectionFactoryManagedImpl and rollbacks

Hi Armin,

I am very sorry to come back to the same topic after such a long time, 
but we are super bussy to get our thing up and running.

we are using the Persistent Broker API in an managed enviroment as jboss 
or OC4J (oracle application server). using the 
ojb.org.apache.ojb.broker.accesslayer.ConnectionFactoryManagedImpl from
OJB with jboss I see the following log:

-------------------------------------------------------------------------------

[ejb.ojb.org.apache.ojb.broker.accesslayer.ConnectionManagerImpl] 
(Thread-10) Rollback was called, do rollback on current connection 
org.apache.ojb.broker.util.pooling.ByPassConnection@a0c486

[ejb.ojb.org.apache.ojb.broker.accesslayer.ConnectionManagerImpl] 
(Thread-10) Rollback on the underlying connection failed
java.sql.SQLException: You cannot rollback during a managed transaction!
	at 
org.jboss.resource.adapter.jdbc.local.LocalManagedConnection.jdbcRollback(LocalManagedConnection.java:478)
	at 
org.jboss.resource.adapter.jdbc.local.LocalConnection.rollback(LocalConnection.java:457)
	at org.apache.ojb.broker.util.WrappedConnection.rollback(Unknown Source)
	at org.apache.ojb.broker.util.pooling.ByPassConnection.rollback(Unknown 
Source)
	at 
org.apache.ojb.broker.accesslayer.ConnectionManagerImpl.localRollback(Unknown 
Source)
	at 
org.apache.ojb.broker.core.PersistenceBrokerImpl.abortTransaction(Unknown 
Source)
	at 
org.apache.ojb.broker.core.DelegatingPersistenceBroker.abortTransaction(Unknown 
Source)

-------------------------------------------------------------------------------

if I use an implentation which produces connections with a NOOP-rollback 
method, than I see only:

-------------------------------------------------------------------------------

[ejb.ojb.org.apache.ojb.broker.accesslayer.ConnectionManagerImpl] 
(Thread-11) Rollback was called, do rollback on current connection 
com.jentro.manager.persistent.ojb.ByPassConnection@10c29fe
14:00:20,312 INFO  [STDOUT] ** we ignore rollback

-------------------------------------------------------------------------------

when I understand the JDO spec correct, than the transaction borders is 
done by the embedding enviroment only.

so altogether our own implementation works fine on jboss and on OC4J 
with our connection factory.

FYI: OJB really helped us a lot to have an application which deploys 
easiely on serveral application servers !!

hope you find the time for checking it.

best wishes Kristian



Armin Waibel wrote:
 > Hi Kristian,
 >
 > sorry for the late reply.
 > In next future I didn't find the time to check
 > your proposal to make rollback() a noop in
 > ConnectionFactoryManaged Impl, but sounds
 > correct. In a managed environment there is no
 > need (think it's not allowed) to rollback
 > connection.
 > What's your experience with the changed Factory?
 > Which API do you use (odmg, pb)?
 >
 > regards,
 > Armin
 >
 > ----- Original Message -----
 > From: "kristian meier" <kr...@jentro.com>
 > To: "OJB Users List" <oj...@db.apache.org>
 > Sent: Friday, September 12, 2003 5:04 PM
 > Subject: ConnectionFactoryManagedImpl and rollbacks
 >
 >
 >
 >>Hello,
 >>
 >>we are using OJB on an application server, in the moment JBoss.
 >>everything works fine until
 >>there comes an exception and the PersistentBroker gets closed without
 >
 > a
 >
 >>commit.
 >>
 >>in the  close()-method the broker does a rollback on the underlying
 >>connection-object and with
 >>the ByPassConnection the rollback is then triggered on the underlying
 >>connection-object.
 >>
 >>now my exception is caught by the EJB-container and again a rollback
 >
 > is
 >
 >>triggered on the current transaction,
 >>which generates another exception from the EJB-container.
 >>
 >>we have seen this behaviour also on WebSphere and on
 >>SunONE-Applicationserver.
 >>
 >>things seemed to be better after we used our own
 >>ConnectionFactoryManagedImpl  where the rollback()-method
 >>is also no-op.
 >>
 >>do I miss something, why the rollback()-method is needed as is in an
 >>applcation-server-scenario ?
 >>
 >>some hints are welcome to understand better what is going on here,
 >
 > thank you
 >
 >>Kristian
 >>

-- 
----------------------------------------------------------------------
  Jentro Technologies GmbH
  Kristian Meier, Developer
----------------------------------------------------------------------
  Rosenheimer Str. 145e     81671 Munich, Germany
  Tel. +49 89 189 169 80    mailto: Kristian.Meier@jentro.com
  Fax. +49 89 189 169 99    internet: http://www.jentro.com
----------------------------------------------------------------------


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


Re: How to restrict result of 1:N mappings

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi guido,

the first parmeter passed to customizeQuery is the owner object so you 
can get values from there as well. attributes defined in the repository 
are static.

hth
jakob

Guido Beutler wrote:
> Hi Jakob,
> 
> ok, first QueryCustomizer implementation is working :-)      Thanks!
> 
> Now I got the next question. How should I pass values on the fly to my 
> customizer.
> I would like to restrict the collection to one value and at my test case 
> I already have the
> primary key of the row. But how can I pass this value to my customizer?
> I saw that I could add attributes at the deployment descriptor but the 
> value of the
> primary key changes dynamically during my application.
> 
> My sample:
> 
>    public Query customizeQuery(Object anObject, PersistenceBroker 
> aBroker, CollectionDescriptor aCod, QueryByCriteria aQuery)
>    {
>       aQuery.getCriteria().addEqualTo("field","value");
>        return aQuery;
>    }
> 
> The "value" should change dynamically. Could somebody give me a 
> aditional hint?
> 
> best regards,
> 
> Guido
> 
> Jakob Braeuchi wrote:
> 
>> hi guido,
>>
>> please have a look at the query customizer.
>>
>> jakob
>>
>> Guido Beutler wrote:
>>
>>> Hello,
>>>
>>> I've got a 1:N mapping between classes. I would like to restrict the 
>>> entries at the retrieved collection.
>>>
>>> I got two Classes A and B with a 1:n mapping between it. B has >17000 
>>> entries so I would like
>>> to restrict the collection to a small set of B's by using the primary 
>>> key of B.
>>> By using a path expression I get the correct A but the collection 
>>> from A to B contains all values of B
>>> not only the ones with the given b.pk .
>>>
>>> Could somebody give me a hint where to look at?
>>>
>>> Thanks in advance, best regards,
>>>
>>> Guido
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
> 
> 
> 
> ---------------------------------------------------------------------
> 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: How to restrict result of 1:N mappings

Posted by Guido Beutler <gu...@hrs.de>.
Hi Jakob,

ok, first QueryCustomizer implementation is working :-)      
Thanks!

Now I got the next question. How should I pass values on the fly to my 
customizer.
I would like to restrict the collection to one value and at my test case 
I already have the
primary key of the row. But how can I pass this value to my customizer?
I saw that I could add attributes at the deployment descriptor but the 
value of the
primary key changes dynamically during my application.

My sample:

    public Query customizeQuery(Object anObject, PersistenceBroker 
aBroker, CollectionDescriptor aCod, QueryByCriteria aQuery)
    {
       aQuery.getCriteria().addEqualTo("field","value");
        return aQuery;
    }

The "value" should change dynamically. Could somebody give me a 
aditional hint?

best regards,

Guido

Jakob Braeuchi wrote:

> hi guido,
>
> please have a look at the query customizer.
>
> jakob
>
> Guido Beutler wrote:
>
>> Hello,
>>
>> I've got a 1:N mapping between classes. I would like to restrict the 
>> entries at the retrieved collection.
>>
>> I got two Classes A and B with a 1:n mapping between it. B has >17000 
>> entries so I would like
>> to restrict the collection to a small set of B's by using the primary 
>> key of B.
>> By using a path expression I get the correct A but the collection 
>> from A to B contains all values of B
>> not only the ones with the given b.pk .
>>
>> Could somebody give me a hint where to look at?
>>
>> Thanks in advance, best regards,
>>
>> Guido
>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>



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


Re: How to restrict result of 1:N mappings

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi guido,

please have a look at the query customizer.

jakob

Guido Beutler wrote:

> Hello,
> 
> I've got a 1:N mapping between classes. I would like to restrict the 
> entries at the retrieved collection.
> 
> I got two Classes A and B with a 1:n mapping between it. B has >17000 
> entries so I would like
> to restrict the collection to a small set of B's by using the primary 
> key of B.
> By using a path expression I get the correct A but the collection from A 
> to B contains all values of B
> not only the ones with the given b.pk .
> 
> Could somebody give me a hint where to look at?
> 
> Thanks in advance, best regards,
> 
> Guido
> 
> 
> ---------------------------------------------------------------------
> 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


How to restrict result of 1:N mappings

Posted by Guido Beutler <gu...@hrs.de>.
Hello,

I've got a 1:N mapping between classes. I would like to restrict the 
entries at the retrieved collection.

I got two Classes A and B with a 1:n mapping between it. B has >17000 
entries so I would like
to restrict the collection to a small set of B's by using the primary 
key of B.
By using a path expression I get the correct A but the collection from A 
to B contains all values of B
not only the ones with the given b.pk .

Could somebody give me a hint where to look at?

Thanks in advance, best regards,

Guido


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


Re: old thread: Re: ConnectionFactoryManagedImpl and rollbacks

Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi Kristian,

I will try to test ConnectionFactoryManagedImpl with a noop-rollback 
methods ASAP. Currently I'm very busy with other OJB stuff.
Please remember me (with severe criticism) again if I don't post my 
experience within the next few days ;-)

regards,
Armin

kristian meier wrote:

> Hi Armin,
> 
> I am very sorry to come back to the same topic after such a long time, 
> but we are super bussy to get our thing up and running.
> 
> we are using the Persistent Broker API in an managed enviroment as jboss 
> or OC4J (oracle application server). using the 
> ojb.org.apache.ojb.broker.accesslayer.ConnectionFactoryManagedImpl from
> OJB with jboss I see the following log:
> 
> ------------------------------------------------------------------------------- 
> 
> 
> [ejb.ojb.org.apache.ojb.broker.accesslayer.ConnectionManagerImpl] 
> (Thread-10) Rollback was called, do rollback on current connection 
> org.apache.ojb.broker.util.pooling.ByPassConnection@a0c486
> 
> [ejb.ojb.org.apache.ojb.broker.accesslayer.ConnectionManagerImpl] 
> (Thread-10) Rollback on the underlying connection failed
> java.sql.SQLException: You cannot rollback during a managed transaction!
>     at 
> org.jboss.resource.adapter.jdbc.local.LocalManagedConnection.jdbcRollback(LocalManagedConnection.java:478) 
> 
>     at 
> org.jboss.resource.adapter.jdbc.local.LocalConnection.rollback(LocalConnection.java:457) 
> 
>     at org.apache.ojb.broker.util.WrappedConnection.rollback(Unknown 
> Source)
>     at 
> org.apache.ojb.broker.util.pooling.ByPassConnection.rollback(Unknown 
> Source)
>     at 
> org.apache.ojb.broker.accesslayer.ConnectionManagerImpl.localRollback(Unknown 
> Source)
>     at 
> org.apache.ojb.broker.core.PersistenceBrokerImpl.abortTransaction(Unknown 
> Source)
>     at 
> org.apache.ojb.broker.core.DelegatingPersistenceBroker.abortTransaction(Unknown 
> Source)
> 
> ------------------------------------------------------------------------------- 
> 
> 
> if I use an implentation which produces connections with a NOOP-rollback 
> method, than I see only:
> 
> ------------------------------------------------------------------------------- 
> 
> 
> [ejb.ojb.org.apache.ojb.broker.accesslayer.ConnectionManagerImpl] 
> (Thread-11) Rollback was called, do rollback on current connection 
> com.jentro.manager.persistent.ojb.ByPassConnection@10c29fe
> 14:00:20,312 INFO  [STDOUT] ** we ignore rollback
> 
> ------------------------------------------------------------------------------- 
> 
> 
> when I understand the JDO spec correct, than the transaction borders is 
> done by the embedding enviroment only.
> 
> so altogether our own implementation works fine on jboss and on OC4J 
> with our connection factory.
> 
> FYI: OJB really helped us a lot to have an application which deploys 
> easiely on serveral application servers !!
> 
> hope you find the time for checking it.
> 
> best wishes Kristian
> 
> 
> 
> Armin Waibel wrote:
>  > Hi Kristian,
>  >
>  > sorry for the late reply.
>  > In next future I didn't find the time to check
>  > your proposal to make rollback() a noop in
>  > ConnectionFactoryManaged Impl, but sounds
>  > correct. In a managed environment there is no
>  > need (think it's not allowed) to rollback
>  > connection.
>  > What's your experience with the changed Factory?
>  > Which API do you use (odmg, pb)?
>  >
>  > regards,
>  > Armin
>  >
>  > ----- Original Message -----
>  > From: "kristian meier" <kr...@jentro.com>
>  > To: "OJB Users List" <oj...@db.apache.org>
>  > Sent: Friday, September 12, 2003 5:04 PM
>  > Subject: ConnectionFactoryManagedImpl and rollbacks
>  >
>  >
>  >
>  >>Hello,
>  >>
>  >>we are using OJB on an application server, in the moment JBoss.
>  >>everything works fine until
>  >>there comes an exception and the PersistentBroker gets closed without
>  >
>  > a
>  >
>  >>commit.
>  >>
>  >>in the  close()-method the broker does a rollback on the underlying
>  >>connection-object and with
>  >>the ByPassConnection the rollback is then triggered on the underlying
>  >>connection-object.
>  >>
>  >>now my exception is caught by the EJB-container and again a rollback
>  >
>  > is
>  >
>  >>triggered on the current transaction,
>  >>which generates another exception from the EJB-container.
>  >>
>  >>we have seen this behaviour also on WebSphere and on
>  >>SunONE-Applicationserver.
>  >>
>  >>things seemed to be better after we used our own
>  >>ConnectionFactoryManagedImpl  where the rollback()-method
>  >>is also no-op.
>  >>
>  >>do I miss something, why the rollback()-method is needed as is in an
>  >>applcation-server-scenario ?
>  >>
>  >>some hints are welcome to understand better what is going on here,
>  >
>  > thank you
>  >
>  >>Kristian
>  >>
> 



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