You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Mykola Ostapchuk <my...@sympatico.ca> on 2003/07/09 19:22:06 UTC
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: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Can't instantiate query
Posted by Mykola Ostapchuk <my...@sympatico.ca>.
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" <my...@sympatico.ca>
To: <oj...@db.apache.org>
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: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org