I solved the problem by using
Query query = new QueryByCriteria(CountriesVO.class, criteria);

I'm wandering why
Query query = QueryFactory.newQuery(CountriesVO.class,criteria);
doesn't work in OJB 1.0.rc3?..

Regards,
Mykola

----- Original Message ----- 
From: "Mykola Ostapchuk" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 09, 2003 1:22 PM
Subject: Can't instantiate query


> Hi,
>
> I can't instantiate query with the next line:
> Query query = QueryFactory.newQuery(CountriesVO.class, criteria);
> It generates error and method returns null.
> The method worked well with OJB 0.9.7, now I'm using OJB 1.0.rc3.
> Does anybody have any idea what can be wrong?
>
> One more question: I don't understand why catch (Exception e)  doesn't
> actually cach an Exception?
> I've System.out and log.error in catch statement - none of them prints
> nothing.
>
> Here's my method:
>
>
> public Vector allCountries() throws DataAccessException {
>         log.info("************Entering the
> CountriesDAO.allCountries()***************");
>         PersistenceBroker broker = null;
>         Vector results = null;
>         try{
>             Criteria criteria = new Criteria();
>             criteria.addOrderBy("CO_name");
>             Query query = QueryFactory.newQuery(CountriesVO.class,
> criteria);
>             query.setStartAtIndex(1);
>             broker = PersistenceBrokerFactory.defaultPersistenceBroker();
>             results = (Vector) broker.getCollectionByQuery(query);
>         }
>         catch (Exception e) {
>             System.out.println("Error: "+e.toString());
>             log.error("Exception thrown in CountriesDAO.allCountries(): "
+
> e.toString());
>         }
>         finally {
>             if (broker != null) broker.close();
>         }
>         log.info("************Done with
> CountriesDAO.allCountries()***************");
>         return results;
>     }
>
>
>
> Please, help!
>
> Regards,
> Mykola
>
>
> ---------------------------------------------------------------------
> 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]

Reply via email to