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 Suma Venkatesh <su...@yahoo.com> on 2004/01/12 00:06:33 UTC
Calling custom store procedures in OJB
Hi all,
Iam working on using store procedures using OJB. I want to call a
store procedure which selects a number of items from a table Product.I
want to be able to use a store procedure to do this and not a simple
select and query by collection.
I checked the repository.dtd which defines no such element. Is there
a way to acheive this in OJB ?
To summarize: Is there a way to call a custom store procedure which does NO insert,delete,update operations and just does some select operations in OJB.
Please help me as Iam totally new to OJB!!
thanks in advance,
suma
Armin Waibel <ar...@code-au-lait.de> wrote:
Hi Raymond,
> 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: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
---------------------------------
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes