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/core PersistenceBrokerImpl.java
Date Fri, 14 Jan 2005 01:35:42 GMT
arminw      2005/01/13 17:35:42

  Modified:    src/java/org/apache/ojb/broker/core Tag: OJB_1_0_RELEASE
                        PersistenceBrokerImpl.java
  Log:
  workaround, fix problem when using PB#getObjectByQuery(...) with QueryByIdentity and 'null'
PK fields
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.83.2.10 +11 -7     db-ojb/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java
  
  Index: PersistenceBrokerImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java,v
  retrieving revision 1.83.2.9
  retrieving revision 1.83.2.10
  diff -u -r1.83.2.9 -r1.83.2.10
  --- PersistenceBrokerImpl.java	12 Dec 2004 01:49:43 -0000	1.83.2.9
  +++ PersistenceBrokerImpl.java	14 Jan 2005 01:35:42 -0000	1.83.2.10
  @@ -1524,20 +1524,25 @@
        */
       public Object getObjectByQuery(Query query) throws PersistenceBrokerException
       {
  +        Object result = null;
           if (query instanceof QueryByIdentity)
           {
               // example obj may be an entity or an Identity
               Object obj = query.getExampleObject();
  -            Identity oid = null;
               if (obj instanceof Identity)
               {
  -                oid = (Identity) obj;
  +                Identity oid = (Identity) obj;
  +                result = getObjectByIdentity(oid);
               }
               else
               {
  -                oid = new Identity(obj, this);
  +                // TODO: This workaround doesn't allow 'null' for PK fields  
  +                if (!serviceBrokerHelper().hasNullPKField(getClassDescriptor(obj.getClass()),
obj))
  +                {
  +                    Identity oid = serviceIdentity().buildIdentity(obj);
  +                    result = getObjectByIdentity(oid);
  +                }
               }
  -            return getObjectByIdentity(oid);
           }
           else
           {
  @@ -1548,7 +1553,6 @@
               resources instantly
               */
               OJBIterator it = getIteratorFromQuery(query, cld);
  -            Object result = null;
               /*
               arminw:
               patch by Andre Clute, instead of taking the first found result
  @@ -1571,8 +1575,8 @@
               {
                   if(it != null) it.releaseDbResources();
               }
  -            return result;
           }
  +        return result;
       }
   
       /**
  
  
  

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