Hi Armin,

I solved the issue. It was indeed a second broker connection open... (was
hard to track...). Anyway, I posted the jdbc connection descriptor settings
and the source code. I should mention that we have a
PersistenceManagerFactory which will be called on web-app startup and
initializes a concrete PersistenceManager (in this case OJB-PB).  This
object is stored in servlet context and can be retrieved on request. The
source code reflects a 1:CN relationship between Activity and Module. Can
you advised me, is this the common approach I took or is there a better way?
thx, Dirk

<descriptor-repository version="1.0" isolation-level="read-uncommitted"
proxy-prefetching-limit="50">
        <!-- include all used database connections -->
        <jdbc-connection-descriptor
                jcd-alias="default"
                default-connection="true"
                platform="Hsqldb"
                jdbc-level="2.0"
                driver="org.hsqldb.jdbcDriver"
                protocol="jdbc"
                subprotocol="hsqldb:hsql"
                dbalias="//localhost"
                username="sa"
                password=""
        eager-release="false"
                batch-mode="false"
        useAutoCommit="2"
        ignoreAutoCommitExceptions="false"
     >
        <connection-pool
            maxActive="21"
            validationQuery="" />

        <sequence-manager
className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl">
            <attribute attribute-name="grabSize" attribute-value="20"/>
            <attribute attribute-name="autoNaming" attribute-value="true"/>
            <attribute attribute-name="globalSequenceId"
attribute-value="false"/>
            <attribute attribute-name="globalSequenceStart"
attribute-value="10000"/>
        </sequence-manager>
   </jdbc-connection-descriptor>


source:

                try{
                        pm.beginTransaction();

                        pm.storeObject(activityModel);
                }
                catch(Exception e){
                        //TODO catch-Klausel kommentieren
                        e.printStackTrace();

                        if(logger.isDebugEnabled())
                                logger.debug("INSERT Aktivit�t failed.");
                }

                //Attribute f�r TMODUL setzen
                String moduleId =
((String)PropertyUtils.getSimpleProperty(form, "strModuleId"));

                if(moduleId != null && !moduleId.equals("-1")){
                        try{
                                //Instanz von ActivityModel mit ActivityId
holen
                                object = pm.getObjectId(activityModel);
                        }
                        catch(Exception e){
                                //TODO catch-Klausel kommentieren
                                e.printStackTrace();

                                if(logger.isDebugEnabled())
                                        logger.debug("ObjectId could not be
retrieved.");
                        }

                        if(object != null && object instanceof
ActivityModel){
                                activityModel = (ActivityModel)object;

                                //checkbox auswerten
                                String moduleExclusive =
((String)PropertyUtils.getSimpleProperty(form, "strModuleExclusive"));

                                if(moduleExclusive == null ||
moduleExclusive.length()<1)
                                        moduleExclusive = "no";

                                moduleModel = new ModuleModel();

        
moduleModel.setIntModuleId(Integer.parseInt(moduleId));
        
moduleModel.setStrModuleExclusive(moduleExclusive);
                                moduleModel.setActivityModel(activityModel);
        
moduleModel.setValidFromTimepoint(activityModel.getValidFromTimepoint());
                                moduleModel.setVersionNr(0);
        
moduleModel.setValidToTimepoint(activityModel.getValidToTimepoint());
        
moduleModel.setTimestamp(activityModel.getTimestamp());
        
moduleModel.setStrUserId(activityModel.getStrUserId());
        
moduleModel.setStrProgram(Constant.PROGRAM_NAME);
                        }
                }

                try{
                        if(moduleModel != null){
                                pm.storeObject(moduleModel);
                        }

                        pm.commitTransaction();

                        pm.close();
                }
                catch(Exception e){
                        //TODO catch-Klausel kommentieren
                        e.printStackTrace();

                        pm.rollbackTransaction();

                        if(logger.isDebugEnabled())
                                logger.debug("INSERT Activity/Module failed.
Transaction rolled back.");

                        return
(mapping.findForward(Constant.DATABASE_ERROR_INSERT));
                }
                finally{
                        pm.close();
                }
 

-----Urspr�ngliche Nachricht-----
Von: Armin Waibel [mailto:[EMAIL PROTECTED] 
Gesendet: Dienstag, 30. Dezember 2003 16:57
An: OJB Users List
Betreff: Re: AW: AW: how can i do multiple operations in one transaction?

more questions:

Armin Waibel wrote:

> Hi Dirk,
> 
> I can't believe that PB-api is the problem. Can you post a junit test 
> (or a modified test from test suite) to reproduce the problem?
> 
> What calculations you are doing, do you use the ConnectionManager?
> Do you set eager-release 'true' in jdbc-connection-descriptor?
> Do you use batch mode?
Could it be a multithreaded problem?
Do you lookup the PB instance twice in your code?

Armin

> 
> regards,
> Armin
> 
> Dirk Manske (Service Respond) wrote:
> 
>> Hi Armin,
>>
>> no, as ConnectionFactoryClass I use ConnectionFactoryPooledImpl. 
>> While the process runs there is only one OJB object (the pm object, 
>> see code
>> snippet)
>> and I do not use further data sources. All database operations are 
>> only handled by PB.
>>
>> greets,
>> Dirk
>>   
>> -----Urspr�ngliche Nachricht-----
>> Von: Armin Waibel [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 
>> 30. Dezember 2003 16:18
>> An: OJB Users List
>> Betreff: Re: AW: how can i do multiple operations in one transaction?
>>
>> Hi Dirk,
>>
>> hmm, this shouldn't be a problem. Do you use any connection object 
>> from OJB while performing your test?
>> Do you use ConnectionFactoryManagedImpl in OJB.properties file as 
>> ConnectionFactoryClass?
>> Do you use DataSource?
>>
>> regards,
>> Armin
>>
>> Dirk Manske (Service Respond) wrote:
>>
>>> Hi Wally,
>>>
>>> auto-commit is set to "2" = off. I still get an
>>> org.apache.ojb.broker.TransactionNotInProgressException: 
>>> ConnectionManager is NOT in transaction. This exception is thrown 
>>> after pm.commitTransaction() is executed. However, if I comment this 
>>> out, it runs well, both objects are stored. I really got stucked on 
>>> this.
>>
>>
>> Any idea?
>>
>>> thx,
>>> Dirk
>>>  
>>>
>>> -----Urspr�ngliche Nachricht-----
>>> Von: Gelhar, Wallace Joseph [mailto:[EMAIL PROTECTED]
>>> Gesendet: Dienstag, 30. Dezember 2003 05:07
>>> An: OJB Users List
>>> Betreff: RE: how can i do multiple operations in one transaction?
>>>
>>> Hi Dirk,
>>>
>>> PB transactions are database transactions (as opposed to the object 
>>> level transactions provided by ODMG, OTM, and JDO).  Check your 
>>> database connection descriptor to make sure you have autocommit 
>>> turned off.  I suspect that the JDBC connection is autocommiting the 
>>> transaction for you on the store operation.
>>>
>>> Wally
>>>
>>> -----Original Message-----
>>> From: [EMAIL PROTECTED]
>>> [mailto:[EMAIL PROTECTED]
>>> Sent: Monday, December 29, 2003 6:27 PM
>>> To: [EMAIL PROTECTED]
>>> Subject: how can i do multiple operations in one transaction?
>>>
>>> Hi,
>>>
>>> I am using the PersistenceBroker (OJB 1.0 rc5) and have some 
>>> problems to store 2 objects within a single transaction. The problem 
>>> is, that I want to have the whole transaction comitted if and only 
>>> if a calculation between these two store operations has been 
>>> successfull, otherwise the first store operation will be rolled 
>>> back.  Consider the following code
>>> snippet:
>>>
>>> try{
>>>       pm = PersistenceBrokerFactory.defaultPersistenceBroker();
>>>
>>>       pm.beginTransaction();
>>>       pm.store(object1);
>>> }
>>> catch ...
>>>
>>> followed by some calculations then retrieve the first object to get 
>>> the id (which was set by OJB via autoincrement) ...
>>>
>>> try{
>>>      pm.getObjectId(object1);
>>> }
>>> catch ...
>>>
>>> follwed by another operation and if succeeded then store object2 and 
>>> finish the transaction:
>>>
>>> try{
>>>      pm.store(object2);
>>>      pm.comitTransaction();
>>>      pm.close();
>>> }
>>> catch...
>>>
>>> I always get a TransactionNotInProgressException. How can I solve 
>>> this problem?
>>>
>>> thx,
>>> Dirk
>>>
>>>     
>>>
>>>
>>>
>>>
>>>
>>> --------------------------------------------------------------------
>>> - 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]
>>>
>>>
>>> --------------------------------------------------------------------
>>> - 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]
>>
>>
>> ---------------------------------------------------------------------
>> 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]
> 
> 
> 



---------------------------------------------------------------------
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