db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker Identity.java
Date Sun, 13 Mar 2005 03:50:48 GMT
arminw      2005/03/12 19:50:48

  Modified:    src/java/org/apache/ojb/broker Tag: OJB_1_0_RELEASE
                        Identity.java
  Log:
  sometimes a concurrency issue occur when create Identity object, hope this will fix it:
  synchronize on persistent object while create Identity
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.36.2.6  +26 -23    db-ojb/src/java/org/apache/ojb/broker/Identity.java
  
  Index: Identity.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/Identity.java,v
  retrieving revision 1.36.2.5
  retrieving revision 1.36.2.6
  diff -u -r1.36.2.5 -r1.36.2.6
  --- Identity.java	19 Feb 2005 18:27:19 -0000	1.36.2.5
  +++ Identity.java	13 Mar 2005 03:50:48 -0000	1.36.2.6
  @@ -128,33 +128,36 @@
           {
               IndirectionHandler handler = ProxyHelper.getIndirectionHandler(objectToIdentify);
   
  -            if (handler != null)
  +            synchronized(objectToIdentify)
               {
  -                Identity sourceOID = handler.getIdentity();
  -                m_objectsTopLevelClass = sourceOID.m_objectsTopLevelClass;
  -                m_objectsRealClass = sourceOID.m_objectsRealClass;
  -                m_pkValues = sourceOID.m_pkValues;
  -            }
  -            else
  -            {
  -                if (cld == null)
  +                if (handler != null)
                   {
  -                    cld = targetBroker.getClassDescriptor(objectToIdentify.getClass());
  +                    Identity sourceOID = handler.getIdentity();
  +                    m_objectsTopLevelClass = sourceOID.m_objectsTopLevelClass;
  +                    m_objectsRealClass = sourceOID.m_objectsRealClass;
  +                    m_pkValues = sourceOID.m_pkValues;
                   }
  -
  -                // identities must be unique accross extents !
  -                m_objectsTopLevelClass = targetBroker.getTopLevelClass(objectToIdentify.getClass());
  -                m_objectsRealClass = objectToIdentify.getClass();
  -
  -                // BRJ: definitely do NOT convertToSql
  -                // conversion is done when binding the sql-statement
  -                BrokerHelper helper = targetBroker.serviceBrokerHelper();
  -                ValueContainer[] pkValues = helper.getKeyValues(cld, objectToIdentify,
false);
  -                if(pkValues == null || pkValues.length == 0)
  +                else
                   {
  -                    createException("Can't extract PK value fields", objectToIdentify,
null);
  +                    if (cld == null)
  +                    {
  +                        cld = targetBroker.getClassDescriptor(objectToIdentify.getClass());
  +                    }
  +
  +                    // identities must be unique accross extents !
  +                    m_objectsTopLevelClass = targetBroker.getTopLevelClass(objectToIdentify.getClass());
  +                    m_objectsRealClass = objectToIdentify.getClass();
  +
  +                    // BRJ: definitely do NOT convertToSql
  +                    // conversion is done when binding the sql-statement
  +                    BrokerHelper helper = targetBroker.serviceBrokerHelper();
  +                    ValueContainer[] pkValues = helper.getKeyValues(cld, objectToIdentify,
false);
  +                    if(pkValues == null || pkValues.length == 0)
  +                    {
  +                        createException("Can't extract PK value fields", objectToIdentify,
null);
  +                    }
  +                    m_pkValues = helper.extractValueArray(pkValues);
                   }
  -                m_pkValues = helper.extractValueArray(pkValues);
               }
   
               checkForPrimaryKeys(objectToIdentify);
  
  
  

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


Mime
View raw message