db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Warrick <philip.warr...@mcgill.ca>
Subject [Fwd: Per-criteria pathClass [was ojb-user: Query casts] 1 of 2]
Date Sun, 28 Mar 2004 13:12:41 GMT
Hi Jakob,

In case you did not receive these, here they are againDid you not 
receive these?

Phil

-------- Original Message --------
Subject: 	Per-criteria pathClass [was ojb-user: Query casts] 1 of 2
Date: 	Sat, 27 Mar 2004 16:03:47 -0500
From: 	Philip Warrick <Philip.warrick@mcgill.ca>
To: 	undisclosed-recipients <undisclosed-recipients:;>



Hi Jakob,

I've done the changes to allow pathClass to be specified per Criteria
rather than per QueryByCriteria.  The main change from the user point of
view is the addition of the method Criteria#setPathClass().   So the
following query is now possible:

Criteria crit1 = new Criteria();
crit1.setAlias("alias1");
crit1.addEqualTo("allBs.c.cAttrib", new String("foo1"));
crit1.setPathClass("c", C.class); // new: per criteria

Criteria crit2 = new Criteria();
crit2.setAlias("alias2");
crit1.addEqualTo("allBs.c.dAttrib", new String("foo2"));
crit1.setPathClass("c", C1.class); // new: per criteria

crit1.addAndCriteria(crit2);

Query query = new QueryByCriteria(A.class, crit1);


For backward compatibility, QueryByCriteria#setPathClass() is still
available.  What happens is that if no pathClass is specified at a
particular Criteria level, the parent Criteria is searched for a
pathClass, and so on until the parent Criteria.  If no pathClass is
found there, the pathClass of the owning QueryByCriteria is accessed.
I've created a junit test case to test the new functionality; no errors
have been introduced to the existing broker junit tests with these
changes (tested with hsqldb).

I based my changes on the CVS snapshot from 2004/03/14 and notice that
as of this today, no changes have been made since then to the java
source that I changed.  I've marked my changes in the code by my
initials //PAW.  I'd would really like if you could review this code to
see if there is anything you see that is questionable.

I'm not proposing that this should be added before 1.0, but I'd like to
get an iteration out there for feedback before I go ahead with phase II:
    aliases specified by segment.

Summary of attached files (sent in 2 messages):

src files
o.a.o.b.query.Criteria.java
o.a.o.b.query.SelectionCriteria.java
o.a.o.b.query.BetweenCriteria.java
o.a.o.b.accesslayer.sql.SqlQueryStatement.java
o.a.o.b.accesslayer.sql.SqlSelectStatement.java

srcTest files
ojbTest-schema-pathClass.xml
repository-junit-pathClass.xml
o.a.o.b.query.A.java
o.a.o.b.query.B.java
o.a.o.b.query.C.java
o.a.o.b.query.C1.java
o.a.o.b.query.D.java
o.a.o.b.query.PathClassTest.java

test class object model:

A-1------M-B-1------M-C-1------1-D
                         |
                         | (C1 subclass of C)
                         |
                         C1

Thanks,

Phil





Mime
View raw message