Re: [OJB-developers] problem with path expressions and extents
Brought to you by:
thma
From: Jakob B. <jbr...@ho...> - 2002-05-25 12:20:26
|
hi thomas, unfortunately it's not related to buggy extent definition, it's a general problem !!! when the SqlStatement resolves the path expressions ie: 'allArticlesInGroup.id' then it looks up the collection descriptor for 'allArticlesInGroup' in the class definition of productgroup. this collection descriptor references the base class only ( Article ), so SqlStatement will use the table of the base class for the query and thus will not find a productgroup for the CdArticle with id 200. i implemented a kind of hint for SqlStatement: QueryByCriteria#addPathClass(aPathSegment, aClass) ie: addPathClass("allArticlesInGroup", CdArticle.class), so SqlStatement will use the table for CdArticle when building the sql. this stuff is now in cvs, and there's also a testcase for it: QueryTest#testInversePathExpression(). so far it's used only for querying inverse m:n relationships in PersistenceBrokerImpl##getMtoNQuery(). an other cleaner solution would be the use of sql UNION whenever dealing with extents, but mysql currently does not support them. jakob ----- Original Message ----- From: "Thomas Mahler" <tho...@ho...> To: "Jakob Braeuchi" <jbr...@ho...> Cc: <obj...@li...> Sent: Friday, May 24, 2002 8:19 PM Subject: Re: [OJB-developers] problem with path expressions and extents > Hi Jakob, > > I'm not quite sure, but I think this is related to the "buggy" extent > definition for class Article. > > If the InterfaceArticle was used as extent class all would be OK, > without any changes to Query. > > We should setup a new testcase with new persistent classes. The old > Article ProductGroup stuff is messed up a bit. > > > HTH, > > Thomas > > Jakob Braeuchi wrote: > > > hi all, > > > > we have a general problem when using path expression and extents. > > the following test case reads a cd (an extent of article) and then tries to > > read the product group using the relationship 'allArticlesInGroup' belonging > > to this cd in a second query. the second query cannot find the productgroup > > because 'allArticlesInGroup' refers to Article and not to Cd, so the > > article-table is used in the join: > > > > SELECT A0.Kategorie_Nr,A0.KategorieName,A0.Beschreibung FROM Kategorien A0 > > INNER JOIN Artikel A1 ON A0.Kategorie_Nr=A1.Kategorie_Nr WHERE A1.Artikel_Nr > > = ? > > > > the query returning the correct result: > > > > SELECT A0.Kategorie_Nr,A0.KategorieName,A0.Beschreibung FROM Cds A0 INNER > > JOIN Artikel A1 ON A0.Kategorie_Nr=A1.Kategorie_Nr WHERE A1.Artikel_Nr = ? > > > > i think we need some kind of hints for path expression, so SqlStatement > > knows which tables to use. > > the hints can be set on Criteria or Query level: > > > > query.useClass("AllProductsInGroup", Cd.class) > > > > > > Query query; > > Criteria crit; > > CdArticle cd; > > ProductGroup pg; > > > > System.out.println("\nread a single cd"); > > crit = new Criteria(); > > crit.addEqualTo("articleId", new Integer(200)); > > query = new QueryByCriteria(CdArticle.class, crit); > > cd = (CdArticle) broker.getObjectByQuery(query); > > System.out.println(cd); > > > > System.out.println("\nread product group for cd"); > > crit = new Criteria(); > > crit.addEqualTo("allArticlesInGroup.articleId",new > > Integer(cd.getArticleId())); > > query = new QueryByCriteria(ProductGroup.class, crit); > > pg = (ProductGroup) broker.getObjectByQuery(query); > > System.out.println(pg); > > > > this kind of query may look a little exotic in the above sample, but it's > > the kind of query used in non decomposed m:n relationship. so we definitely > > need a solution here. > > > > any help will be appreciated. > > > > > > > > > jakob > > > > _______________________________________________________________ > > > > Don't miss the 2002 Sprint PCS Application Developer's Conference > > August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm > > > > _______________________________________________ > > Objectbridge-developers mailing list > > Obj...@li... > > https://lists.sourceforge.net/lists/listinfo/objectbridge-developers > > > > > > > > > > > > _______________________________________________________________ > > Don't miss the 2002 Sprint PCS Application Developer's Conference > August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm > > _______________________________________________ > Objectbridge-developers mailing list > Obj...@li... > https://lists.sourceforge.net/lists/listinfo/objectbridge-developers > |