Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 99023 invoked from network); 14 Jan 2005 01:43:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 14 Jan 2005 01:43:30 -0000 Received: (qmail 42948 invoked by uid 500); 14 Jan 2005 01:43:30 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 42745 invoked by uid 500); 14 Jan 2005 01:43:29 -0000 Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "OJB Developers List" Reply-To: "OJB Developers List" Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 42727 invoked by uid 500); 14 Jan 2005 01:43:29 -0000 Received: (qmail 42724 invoked by uid 99); 14 Jan 2005 01:43:29 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Thu, 13 Jan 2005 17:43:28 -0800 Received: (qmail 99004 invoked by uid 1510); 14 Jan 2005 01:43:27 -0000 Date: 14 Jan 2005 01:43:27 -0000 Message-ID: <20050114014327.99003.qmail@minotaur.apache.org> From: arminw@apache.org To: db-ojb-cvs@apache.org Subject: cvs commit: db-ojb/src/java/org/apache/ojb/broker/core PersistenceBrokerImpl.java X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N arminw 2005/01/13 17:43:27 Modified: src/java/org/apache/ojb/broker/core PersistenceBrokerImpl.java Log: workaround, fix problem when using PB#getObjectByQuery(...) with QueryByIdentity and 'null' PK fields Revision Changes Path 1.109 +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.108 retrieving revision 1.109 diff -u -r1.108 -r1.109 --- PersistenceBrokerImpl.java 6 Jan 2005 21:00:00 -0000 1.108 +++ PersistenceBrokerImpl.java 14 Jan 2005 01:43:27 -0000 1.109 @@ -1626,20 +1626,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 { @@ -1650,7 +1655,6 @@ resources instantly */ OJBIterator it = getIteratorFromQuery(query, cld); - Object result = null; /* arminw: patch by Andre Clute, instead of taking the first found result @@ -1673,8 +1677,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