Re: [Objectbridge-developers] ObjectBridge problem
Brought to you by:
thma
From: Thomas M. <tho...@ho...> - 2001-06-02 07:27:31
|
Hi David, hi Sascha, thanks for the bug fix! I will include the fix (and a corresponding unit test) in the next release. I did not discover this bug earlier because I composed such statements just the other way round (like STATE = 3 AND (ID = 10 OR ID = 12)) which works quite well... Thanks again, Thomas David Forslund wrote: > > Sascha has arrived at the solution to the problem we posted. > > There is a problem in the SqlGenerator with the priority of AND and > OR. > In SqlGenerator we need to "wrap" the prior generated statement with > parentheses to make the logic correct: > > switch (pc.getType()) > { > case (Criteria.OR): > { > statement.append( " OR > " + addAtStart); > statement.append(asSQLStatement(pc, > cld)); > statement.append(addAtEnd); > break; > } > case (Criteria.AND): > { > statement.insert(0,"( > "); > statement.append( ") > "); > statement.append(" AND > "+addAtStart); > statement.append(asSQLStatement(pc, > cld)); > statement.append(addAtEnd); > break; > } > > And further down: > SelectionCriteria c = > (SelectionCriteria) o; > if (statement.length() == 0) > { > statement.append(asSQLClause(c, > cld)); > } > else > { > statement.insert(0,"("); > statement.append(") "); > statement.append(" AND "); > statement.append(asSQLClause(c, > cld)); > } > > Apparently there are no junit tests for any complex queries, which > should have uncovered this problem. > This is still a problem in the just released 0.5.136 version. > > Dave > At 12:11 PM 6/1/2001 -0600, David Forslund wrote: > > > We have encountered a problem with Objectbridge and are working on a > > solution, but don't have it yet. We have a query with our search > > filters in which we combine them together. We have something like: > > > > ID = 10 OR ID = 12 AND (STATE = 3) > > > > generated by OJBSearchFilter. However this apparently is equivalent > > to: > > ID=10 OR (ID = 12 AND STATE = 3) > > > > rather than (ID = 10 OR ID=12) AND (STATE = 3) > > > > It seems that when SqlGenerator checks the isEmbraced flag, it never > > uses it for the top level Criteria. > > > > I'm not sure of the proper fix at this point. > > > > David W. Forslund dw...@la... > > Computer and Computational > > Sciences http://www.acl.lanl.gov/~dwf > > Los Alamos National Laboratory Los Alamos, NM > > 87545 > > 505-665-1907 FAX: 505-665-4939 > > David W. Forslund dw...@la... > Computer and Computational > Sciences http://www.acl.lanl.gov/~dwf > Los Alamos National Laboratory Los Alamos, NM > 87545 > 505-665-1907 FAX: 505-665-4939 |