Joint:
The joint in Path Expresss (Relationship.attribute) declared in criteria, will be OJB
Dynamic processing. Path Expressions supports a variety of relationships from 1: 1, 1: n, m: N.
The following example looks out all articles belonging to the Liquors product group. The relationship between the article and the product group is in the Article class
ProductGroup relationship is created:
Class = "org.apache.ojb.broker.Article" Proxy = "Dynamic" Table = "artikel" > ... Name = "ProductGroup" Class-ref = "org.apache.ojb.broker.productGroup" > reference-descriptor> class-descriptor> Class = "org.apache.ojb.broker.productGroup" Proxy = "org.apache.ojb.broker.productGroupProxy" Table = "kategorien" > ... Name = "groupname" Column = "kategoriename" JDBC-TYPE = "varchar" /> ... class-descriptor> Path Expressions contains the relationship between ProductGroup and GroupName between 1: 1 Criteria crit = new criteria (); crit.Addequalto ("ProductGroup.Groupname", "Liquors"); Query Q = queryfactory.newqury (article.class, crit); Collection results = Broker.getCollectionByQuery (q); If Path Express is pointing to a restricted class, then the query condition becomes ORED. Below Query all article names of ProductGroups with f. Path Expressions declares AllarticleSingR OUP to represent Articles restrictions: Books and CDS: Criteria crit = new criteria (); Crit.Addlike ("ALARTICLESINGROUP.ArticleName", "F%"); Query q = queryfactory.newquery (productGroup.class, crit, true); Collection results = Broker.getCollectionByQuery (q); The SQL statement is as follows: Select distinct a0.kategoriename, a0.kategorie_nr, a0.beschreibungfrom 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%' Prefetched relationship: It is possible to minimize the number of queries in the relationship query object. In our test, we specify productGroup S and Articles have a pair of relationships. Get productGroup when Query ProductGroups s, we get its Articles by querying for each productGroup. OJB tries to get all the Ariticles that belong to ProductGroups through a query through the PrefetChed relationship. Let's take a look at why a query is basically unable to implement: Criteria crit = new criteria (); Crit.addlessorequalthan ("GroupID", New Integer (5)); crit.addorderbyDescending ("groupid"); crit.addprefetchedReranceShip ("AllarticlesingRoup"); Query Q = queryfactory.newQuery (ProductGroup.class, crit); Collection results = Broker.getCollectionByQuery (q); The first query gains all matching productGroups: Select ... from kategorien a0 where A0.kategorie_nr <=? Order by 3 DESC The second query obtains Articles belonging to ProductGroups from the structure of the first query: Select ... from artikel a0 where a0.kategorie_nr In (?,?,?,?) ORDER BY 7 DESC After obtaining all relevant Articles, this method does not support the use of Arrays to the relationship. Query object: OJB query returns a full object, which means that all instance variables are assigned, all automatic access Loaded. So far, there is no way to get only partial objects (such as getting the FIR of Personde) STNAME and LASTNAME) REPORT query: The Report query is suitable for getting a line of data, but does not make the real business objects. One line of data is a pair Image arrays, through these queries you can define what kind of object properties you want to exist in a line of data. Attribute name It is also possible to include Path Expressions such as 'Owner.address.Street'. ReportQuery # setc Olumns (String [] Columns) defines properties. Note: COLUMNS here is not columns in the database Column's name should be the same as the properties in the query. The following ReportQuery summarizes the number of inventory articles for each productGroup: Criteria crit = new criteria (); Collection results = new vector (); ReportQueryBycriteria Q = queryfactory.newreportQuery ProductGroup.class, crit); // define the 'columns' of the report Q.SetColumns (new string "{" groupname ", "SUM (ALATICLESINGROUP.STOCK", "SUM (ALARTICLESINGROUP.PRICE)"}); crit.Addgroupby ("Groupname"); Iterator iter = Broker.getReportQueryITORBYQUERY (Q);