Hi Jakob,

b. IMHO this solution is not good because you don't know which a extent class
to choose. What if name of a descriptor is the same for many extent?

a. IMHO this is solution. I think that a path could use a cast operator like in
OQL. For 2 case it could be:

// (TestSuite)test.(TestCase)test.caseName

crit.addEqualTo(
"("+TestSuite.class.getName()+")test.(+"TestCase.class.getName()"+)test.caseName",
"test 3");   

but it is not readable for me so may be like this:

crit.addEqualTo("($1)test.($2)test.caseName", "test 3");   
crit.addPathClass (TestSuite.class);
crit.addPathClass (TestCase.class);

???

regards,
Dariusz Kies


--- Jakob Braeuchi <[EMAIL PROTECTED]> wrote:
> hi dariusz,
> 
> i'm thinking of the following solution to this problem:
> 
> a.) pass the hints to getAttributeDescriptorsForPath
> b.)  in getAttributeDescriptorsForPath i'd like to scan the extents if a 
> descriptor can't be found in the class.
> 
> what do you think ?
> 
> jakob
> 
> Dariusz Kies wrote:
> 
> >Hi,
> >
> >Here is the sql for 3:
> >[org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl] DEBUG:
> >SQL: SELECT A0.ID,A0.ID_TEST FROM FI.T_FOO A0,FI.T_TEST_SUITE A1 WHERE
> >A0.ID_TEST=A1.ID AND (caseName =  ? )
> >
> >Notice that there isn't the column name for the caseName attribute and there
> >isn't join with FI.T_TEST_CASE.
> >I debug a little and I found that a problem is in the class
> >org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement, method
> getTableAlias
> >and call 
> >descriptors = getRoot().cld.getAttributeDescriptorsForPath(aPath); // line
> 655
> >This call return only one
>
>element:[EMAIL PROTECTED]
> >delete=false,cascade retrieve=true,cascade store=false,is
> >lazy=false,class of Items=class Test]]
> >It should return three descriptors: TestSuite, TestCase and caseName. 
> >Method getAttributeDescriptorsForPath don't consider the "addPathClass"
> that's
> >way it can't return the good descriptors.
> >
> >
> >Thanks for help
> >Dariusz Kies
> >
> >
> >--- Jakob Braeuchi <[EMAIL PROTECTED]> wrote:
> >  
> >
> >>hi dariusz,
> >>
> >>what is the problem with sample 3 ? can you pleas post the sql or an 
> >>error message ?
> >>
> >>jakob
> >>
> >>Dariusz Kies wrote:
> >>
> >>    
> >>
> >>>Hi,
> >>>
> >>>I have a problem to query on composite pattern in OJB (db-ojb-1.0.rc1).
> >>>Let's assume that I have Test composite pattern from JUnit in OJB:
> >>>
> >>><class-descriptor class="Test" ...>
> >>> <extent-class class-ref="TestCase" />
> >>> <extent-class class-ref="TestSuite" />
> >>> <field-descriptor name="id" primarykey="true" autoincrement="true" ... />
> >>> <field-descriptor name="idTest" ... />
> >>></class-descriptor>
> >>>
> >>><class-descriptor class="TestCase" ...>
> >>> <field-descriptor name="id" primarykey="true" autoincrement="true" ... />
> >>> <field-descriptor name="idTest" ... />
> >>> <field-descriptor name="caseName" jdbc-type="VARCHAR" ... />
> >>></class-descriptor>
> >>>
> >>><class-descriptor class="TestSuite" ...>
> >>> <field-descriptor name="id" primarykey="true" autoincrement="true" ... />
> >>> <field-descriptor name="idTest" ... />
> >>> <field-descriptor name="suiteName" jdbc-type="VARCHAR" ... />
> >>> <collection-descriptor name="test" element-class-ref="Test" ...>
> >>>   <inverse-foreignkey field-ref="idTest"/>
> >>> </collection-descriptor>
> >>></class-descriptor>
> >>>
> >>><class-descriptor class="Foo" ...>
> >>> <field-descriptor name="id" primarykey="true" autoincrement="true" ... />
> >>> <field-descriptor name="idTest" ... />
> >>> <reference-descriptor name="test" class-ref="Test" ...>
> >>>    <foreignkey field-ref="idTest"/>
> >>> </reference-descriptor>
> >>></class-descriptor>
> >>>
> >>>
> >>>1. This works ok:
> >>>Criteria crit = new Criteria();
> >>>crit.addEqualTo("test.caseName", "test 1");
> >>>Query query = QueryFactory.newQuery(Foo.class, crit);
> >>>query.addPathClass("test", TestCase.class);
> >>>Collection results = broker.getCollectionByQuery(query);
> >>>
> >>>
> >>>2. This don't work:
> >>>Criteria crit = new Criteria();
> >>>crit.addEqualTo("test.test.caseName", "test 2");
> >>>Query query = QueryFactory.newQuery(Foo.class, crit);
> >>>query.addPathClass("test", TestSuite.class); // first test
> >>>query.addPathClass("test", TestCase.class);  // second test
> >>>Collection results = broker.getCollectionByQuery(query);
> >>>
> >>>
> >>>3. Still doesn't work:
> >>>
> >>><class-descriptor class="Foo" ...>
> >>> <field-descriptor name="id" primarykey="true" autoincrement="true" ... />
> >>> <reference-descriptor name="aTest" class-ref="Test" ...>
> >>>    <foreignkey field-ref="idTest"/>
> >>> </reference-descriptor>
> >>></class-descriptor>
> >>>
> >>>Criteria crit = new Criteria();
> >>>crit.addEqualTo("aTest.test.caseName", "test 3");
> >>>Query query = QueryFactory.newQuery(Foo.class, crit);
> >>>query.addPathClass("aTest", TestSuite.class);
> >>>query.addPathClass("test", TestCase.class);
> >>>Collection results = broker.getCollectionByQuery(query);
> >>>
> >>>
> >>>Can I query on composite pattern in OJB?
> >>>
> >>>
> >>>Thanks for help
> >>>Dariusz Kies
> >>>
> >>>
> >>>__________________________________________________
> >>>Do you Yahoo!?
> >>>Yahoo! Web Hosting - establish your business online
> >>>http://webhosting.yahoo.com
> >>>
> >>>---------------------------------------------------------------------
> >>>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>>For additional commands, e-mail: [EMAIL PROTECTED]
> >>>
> >>>
> >>> 
> >>>
> >>>      
> >>>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>    
> >>
> >
> >
> >__________________________________________________
> >Do you Yahoo!?
> >Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
> >http://platinum.yahoo.com
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >  
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to