You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by br...@apache.org on 2003/02/16 14:24:32 UTC
cvs commit: db-ojb/xdocs query.xml
brj 2003/02/16 05:24:32
Modified: xdocs query.xml
Log:
sample for extent aware path expression
Revision Changes Path
1.13 +30 -1 db-ojb/xdocs/query.xml
Index: query.xml
===================================================================
RCS file: /home/cvs/db-ojb/xdocs/query.xml,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- query.xml 6 Jan 2003 14:09:20 -0000 1.12
+++ query.xml 16 Feb 2003 13:24:32 -0000 1.13
@@ -205,7 +205,7 @@
<subsection name="joins">
<p>
-Joins resulting from path expressions ("relationship.attribute") in criteria are automatically handled by OJB.
+Joins resulting from <b>path expressions</b> ("relationship.attribute") in criteria are automatically handled by OJB.
Path expressions are supported for all relationships 1:1, 1:n and m:n (decomposed and non-decomposed)
and can be nested.
<br/><br/>
@@ -255,6 +255,35 @@
]]></source>
</p>
+
+<p>
+If path expressions refer to a class having <b>extents</b>, the tables of the extent classes participate in the JOIN and the criteria is ORed. The shown sample queries all ProductGroups having an Article named 'F%'.
+The path expression 'allArticlesInGroup' refers to the class Articles which has two extents: Books and CDs.
+
+<source><![CDATA[
+Criteria crit = new Criteria();
+crit.addLike("allArticlesInGroup.articleName", "F%");
+Query q = QueryFactory.newQuery(ProductGroup.class, crit, true);
+
+Collection results = broker.getCollectionByQuery(q);
+]]></source>
+
+<br/>
+This sample produces the following SQL:
+
+<source><![CDATA[
+SELECT DISTINCT A0.KategorieName,A0.Kategorie_Nr,A0.Beschreibung
+FROM Kategorien A0
+INNER JOIN Artikel A1 ON A0.Kategorie_Nr=A1.Kategorie_Nr
+LEFT OUTER JOIN BOOKS A1E0 ON A0.Kategorie_Nr=A1E0.Kategorie_Nr
+LEFT OUTER JOIN CDS A1E1 ON A0.Kategorie_Nr=A1E1.Kategorie_Nr
+WHERE A1.Artikelname LIKE 'F%' OR
+A1E0.Artikelname LIKE 'F%' OR
+A1E1.Artikelname LIKE 'F%'
+]]></source>
+
+</p>
+
</subsection>
<subsection name="prefetched relationships">