> I suspect it is something still hanging around from rc3 in my paths. > I've updated all the relevant jars (that I can think of), the > OJB.properties, the repository xml files etc.
ok, that's all you can do. hmm, your code works with rc3 and don't work with rc5 - right? If so, sounds like a bug in rc5.
Make OJB jars with target 'jar-debug' instead 'jar', then the line numbers will be included in stack trace.
Could you post the class-descriptor for Employee? I will try to write a test case for your problem.
regards, Armin
Raymond Barlow wrote:
Hi all,
I've been chasing this all day, and have gotten no further *sigh*.
Why does the following code give me a ClassCastException on the getCollectionByQuery??
PersistenceBroker broker = null; Criteria criteria = new Criteria(); criteria.addEqualTo("userName", "test"); Query query = new QueryByCriteria(Employee.class, criteria); try { broker = PersistenceBrokerFactory.defaultPersistenceBroker(); //dies on this line: Collection results = broker.getCollectionByQuery(query); Vector v = new Vector(); v.addAll(results); Employee u = (Employee)v.get(0); System.out.println(u.getUserName()); } catch (Throwable t) { t.printStackTrace(); } finally { if(broker != null) broker.close(); }
stack trace:
org.apache.ojb.broker.PersistenceBrokerException: java.lang.ClassCastException
at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source)
at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source)
at org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Unknown Source)
at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown Source)
at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown Source)
at com.hours28.test.TempTest.test1(TempTest.java:40)
at com.hours28.test.TempTest.main(TempTest.java:28)
Caused by: java.lang.ClassCastException
at org.apache.ojb.broker.accesslayer.BasePrefetcher.prefetchRelationship(Unknown Source)
at org.apache.ojb.broker.core.QueryReferenceBroker.performRetrievalTasks(Unknown Source)
at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source)
... 7 more
I suspect it is something still hanging around from rc3 in my paths. I've updated all the relevant jars (that I can think of), the OJB.properties, the repository xml files etc.
Another strange thing about this is that if I run this twice (ie, after the exception, try it again without restarting the session), it works. Strange. It seems like it just doesn't load classes correctly on the first search for them.
Any suggestions?
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
