Re: [OJB-developers] problem with path expressions and extents
Brought to you by:
thma
From: Thomas M. <tho...@ho...> - 2002-05-24 18:18:58
|
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 > > > > |