Re: API question, replacement for QueryByCriteria(Object)
Antoine Levy-Lambert <[email protected]>
| Newsgroups | gmane.comp.jakarta.ojb.user |
|---|---|
| Message-ID | <[email protected]> |
Hello Armin, On Feb 10, 2007, at 10:04 PM, Armin Waibel wrote: > Hi Antoine, > > Antoine Levy-Lambert wrote: >> Hi, >> I am a slide developer (jakarta slide). I am concerned because >> jakarta slide build fails in Gump. >> One of the errors is due to the following line in >> org.apache.slide.store.ojb.property.ElementListPropertyHandler [1] : >> QueryByCriteria query = new QueryByCriteria >> (propertyPeer); >> From the log of the org.apache.ojb.broker.query.QueryByCriteria >> class (or now interface) [2], the constructor used above was >> removed 2 years and 5 months ago. [3] > > OJB trunk is unstable OJB 2.x (Criteria api based on interfaces). > The OJB_1_0_RELEASE branch is the stable upcoming OJB 1.0.5. > >> slide ships with db-ojb version 1.0.1 (yes, this is old). >> Could someone kindly suggest how to rewrite the construct above >> using the current ojb API ? > > based on latest from OJB_1_0_RELEASE branch (1.0.5): > > // build query out of all non-null fields > Query query = QueryFactory.newQueryByExample(template); > or > // build query based on object identity (all PK's, other fields > will be ignored) > Query query = QueryFactory.newQuery(template); > or > // use findByIdentity, similar to QueryFactory.newQuery(template) > Identity oid = broker.serviceIdentity().buildIdentity > ( PropertyPeer.class, new Long(propertyPeer.getPropertyId())); > propertyPeer = (PropertyPeer) broker.getObjectByIdentity(oid); > > (all examples should work with TRUNK sources too) > > By the way, why do you lookup the PropertyPeer object immediately > after store? I am not familiar with this piece of code, I am a new slide committer, and I am trying to make slide build in gump. I have committed your first suggestion in slide's svn. If you want to have a look at the code of slide which interacts with ojb and suggest improvements, I would be delighted. Thanks very much for your help. Best regards, Antoine > > regards, > Armin > >> Then I could fix gump, and make slide build against the latest db- >> ojb. >> Thanks very much, >> Antoine >> [1] http://svn.apache.org/viewvc/jakarta/slide/trunk/src/stores/ >> org/apache/slide/store/ojb/property/ >> ElementListPropertyHandler.java?revision=208458&view=markup [2] >> http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/ >> broker/query/QueryByCriteria.java?view=log [3] >> Revision 364071 - (view) (download) (annotate) - [select for diffs] >> Modified Fri Aug 27 19:55:43 2004 UTC (2 years, 5 months ago) by brj >> File length: 15700 byte(s) >> Diff to previous 363951 (colored) >> better handling for QueryByExample. criteria is built during runtime. >> constructor QueryByCriteria(Object anExampleObject) removed ! >> --------------------------------------------------------------------- >> 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]