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 Raymond Barlow <rb...@raymanoz.com> on 2004/01/11 23:24:31 UTC
upgrade to RC5, ClassCastException on getCollectionByQuery
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?
--
Regards,
Raymond Barlow
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: upgrade to RC5, ClassCastException on getCollectionByQuery
Posted by Raymond Barlow <rb...@raymanoz.com>.
And here's the stack trace with line numbers:
org.apache.ojb.broker.PersistenceBrokerException:
java.lang.ClassCastException
at
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(QueryReferenceBroker.java:251)
at
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(QueryReferenceBroker.java:263)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(PersistenceBrokerImpl.java:997)
at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(DelegatingPersistenceBroker.java:322)
at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(DelegatingPersistenceBroker.java:322)
at com.hours28.test.TempTest.test1(TempTest.java:42)
at com.hours28.test.TempTest.main(TempTest.java:30)
Caused by: java.lang.ClassCastException
at
org.apache.ojb.broker.accesslayer.BasePrefetcher.prefetchRelationship(BasePrefetcher.java:149)
at
org.apache.ojb.broker.core.QueryReferenceBroker.performRetrievalTasks(QueryReferenceBroker.java:317)
at
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(QueryReferenceBroker.java:187)
at
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(QueryReferenceBroker.java:244)
... 6 more
Thanks for your help!
-Raymond
Armin Waibel 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
>
>
--
Regards,
Raymond Barlow
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
il faut voir au niveau upgrade to RC5, ClassCastException on getCollectionByQuery
Posted by Reda Benzair <re...@smartjog.com>.
Raymond Barlow wrote:
> Hi Armin,
>
> I found Jacob's fixes and incorporated them into my local source
> branch, rebuilt jars etc, and now it all works!!
>
> Thanks Armin. Thanks Jacob.
>
> -Raymond
>
> Armin Waibel wrote:
>
>> Hi Raymond,
>>
>> Jakob has checked in a fix. Will be included
>> in the upcoming 1.0 version.
>>
>> regards,
>> Armin
>>
>> Armin Waibel wrote:
>>
>>> Hi,
>>>
>>> rbarlow@raymanoz.com wrote:
>>>
>>>> Hi Armin,
>>>>
>>>> Ah, right yes, that would make sense. Those 2 classes are not
>>>> instances of
>>>> Collection. They descend from java.lang.Object (ie. does not extend
>>>> anything). The implement ManagableCollection.
>>>>
>>>> This worked for rc3, I guess there's been changes around that
>>>> since. Does
>>>
>>>
>>>
>>>
>>> yes, I think the prefetching mechanism was added since rc3
>>>
>>>> this mean that I now need to descend all my custom list classes from
>>>> Collection?
>>>
>>>
>>>
>>>
>>> hmm, I don't implement this new part, but I assume it's a bug,
>>> because I can't find an note in the release-notes that now all
>>> collection-class need to be instance of collection. And this
>>> wouldn't be make sense because in repository.dtd we say
>>> "This attribute must only specified if the attribute type is not a
>>> java.util.Collection (or subclass) or Array type."
>>>
>>> I will try to add a test case for this problem.
>>>
>>> regards,
>>> Armin
>>>
>>>>
>>>> -Raymond
>>>>
>>>>
>>>>> Hi Raymond,
>>>>>
>>>>> the error occured in method prefetchRelationship(Collection owners)
>>>>> line 149 when a cast for the 1:n references is done.
>>>>> The cast is
>>>>>
>>>>> if (collectionClass != null)
>>>>> {
>>>>> newChildren = (Collection)
>>>>> broker.getCollectionByQuery(collectionClass, queries[i]); //Line 149
>>>>> }
>>>>>
>>>>> Thus I think OJB has problems with one of your collection class in
>>>>> class-descriptor of Employee
>>>>>
>>>>> <collection-descriptor
>>>>> name="contracts"
>>>>>
>>>>> element-class-ref="com.hours28.domain.entity.EmployeeContract"
>>>>> collection-class="com.hours28.domain.entity.EmployeeContractCollection"
>>>>>
>>>>> auto-retreive="true"
>>>>> auto-update="true">
>>>>> <inverse-foreignkey field-ref="employeeId"/>
>>>>> </collection-descriptor>
>>>>>
>>>>> <collection-descriptor
>>>>> name="employeeServiceDetails"
>>>>> element-class-ref="com.hours28.domain.entity.EmployeeServiceDetail"
>>>>> collection-class="com.hours28.domain.entity.EmployeeServiceDetailCollection"
>>>>>
>>>>> auto-retreive="true"
>>>>> auto-update="true">
>>>>> <inverse-foreignkey field-ref="employeeId"/>
>>>>> </collection-descriptor>
>>>>>
>>>>> Are both classes EmployeeContractCollection,
>>>>> EmployeeServiceDetailCollection instance of Collection?
>>>>>
>>>>> regards,
>>>>> Armin
>>>>>
>>>>> Raymond Barlow wrote:
>>>>>
>>>>>
>>>>>> Hi Armin,<snip>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>>>
>>>
>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>
--
*Reda BENZAIR**
*Software Analyst
***
*Phone: +33 (0)1 4996 6324
Fax: +33 (0)1 4996 6405
Mobile: +33 (0)6 6240 6192
reda.benzair@smartjog.com <ma...@smartjog.com>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: upgrade to RC5, ClassCastException on getCollectionByQuery
Posted by Raymond Barlow <rb...@raymanoz.com>.
Hi Armin,
I found Jacob's fixes and incorporated them into my local source branch,
rebuilt jars etc, and now it all works!!
Thanks Armin. Thanks Jacob.
-Raymond
Armin Waibel wrote:
> Hi Raymond,
>
> Jakob has checked in a fix. Will be included
> in the upcoming 1.0 version.
>
> regards,
> Armin
>
> Armin Waibel wrote:
>
>> Hi,
>>
>> rbarlow@raymanoz.com wrote:
>>
>>> Hi Armin,
>>>
>>> Ah, right yes, that would make sense. Those 2 classes are not
>>> instances of
>>> Collection. They descend from java.lang.Object (ie. does not extend
>>> anything). The implement ManagableCollection.
>>>
>>> This worked for rc3, I guess there's been changes around that since.
>>> Does
>>
>>
>>
>> yes, I think the prefetching mechanism was added since rc3
>>
>>> this mean that I now need to descend all my custom list classes from
>>> Collection?
>>
>>
>>
>> hmm, I don't implement this new part, but I assume it's a bug,
>> because I can't find an note in the release-notes that now all
>> collection-class need to be instance of collection. And this wouldn't
>> be make sense because in repository.dtd we say
>> "This attribute must only specified if the attribute type is not a
>> java.util.Collection (or subclass) or Array type."
>>
>> I will try to add a test case for this problem.
>>
>> regards,
>> Armin
>>
>>>
>>> -Raymond
>>>
>>>
>>>> Hi Raymond,
>>>>
>>>> the error occured in method prefetchRelationship(Collection owners)
>>>> line 149 when a cast for the 1:n references is done.
>>>> The cast is
>>>>
>>>> if (collectionClass != null)
>>>> {
>>>> newChildren = (Collection)
>>>> broker.getCollectionByQuery(collectionClass, queries[i]); //Line 149
>>>> }
>>>>
>>>> Thus I think OJB has problems with one of your collection class in
>>>> class-descriptor of Employee
>>>>
>>>> <collection-descriptor
>>>> name="contracts"
>>>> element-class-ref="com.hours28.domain.entity.EmployeeContract"
>>>> collection-class="com.hours28.domain.entity.EmployeeContractCollection"
>>>>
>>>> auto-retreive="true"
>>>> auto-update="true">
>>>> <inverse-foreignkey field-ref="employeeId"/>
>>>> </collection-descriptor>
>>>>
>>>> <collection-descriptor
>>>> name="employeeServiceDetails"
>>>> element-class-ref="com.hours28.domain.entity.EmployeeServiceDetail"
>>>> collection-class="com.hours28.domain.entity.EmployeeServiceDetailCollection"
>>>>
>>>> auto-retreive="true"
>>>> auto-update="true">
>>>> <inverse-foreignkey field-ref="employeeId"/>
>>>> </collection-descriptor>
>>>>
>>>> Are both classes EmployeeContractCollection,
>>>> EmployeeServiceDetailCollection instance of Collection?
>>>>
>>>> regards,
>>>> Armin
>>>>
>>>> Raymond Barlow wrote:
>>>>
>>>>
>>>>> Hi Armin,<snip>
>>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
--
Regards,
Raymond Barlow
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
dernier réponse :::: upgrade to RC5, ClassCastException on getCollectionByQuery
Posted by Reda Benzair <re...@smartjog.com>.
Armin Waibel wrote:
> Hi Raymond,
>
> Jakob has checked in a fix. Will be included
> in the upcoming 1.0 version.
>
> regards,
> Armin
>
> Armin Waibel wrote:
>
>> Hi,
>>
>> rbarlow@raymanoz.com wrote:
>>
>>> Hi Armin,
>>>
>>> Ah, right yes, that would make sense. Those 2 classes are not
>>> instances of
>>> Collection. They descend from java.lang.Object (ie. does not extend
>>> anything). The implement ManagableCollection.
>>>
>>> This worked for rc3, I guess there's been changes around that since.
>>> Does
>>
>>
>>
>> yes, I think the prefetching mechanism was added since rc3
>>
>>> this mean that I now need to descend all my custom list classes from
>>> Collection?
>>
>>
>>
>> hmm, I don't implement this new part, but I assume it's a bug,
>> because I can't find an note in the release-notes that now all
>> collection-class need to be instance of collection. And this wouldn't
>> be make sense because in repository.dtd we say
>> "This attribute must only specified if the attribute type is not a
>> java.util.Collection (or subclass) or Array type."
>>
>> I will try to add a test case for this problem.
>>
>> regards,
>> Armin
>>
>>>
>>> -Raymond
>>>
>>>
>>>> Hi Raymond,
>>>>
>>>> the error occured in method prefetchRelationship(Collection owners)
>>>> line 149 when a cast for the 1:n references is done.
>>>> The cast is
>>>>
>>>> if (collectionClass != null)
>>>> {
>>>> newChildren = (Collection)
>>>> broker.getCollectionByQuery(collectionClass, queries[i]); //Line 149
>>>> }
>>>>
>>>> Thus I think OJB has problems with one of your collection class in
>>>> class-descriptor of Employee
>>>>
>>>> <collection-descriptor
>>>> name="contracts"
>>>> element-class-ref="com.hours28.domain.entity.EmployeeContract"
>>>> collection-class="com.hours28.domain.entity.EmployeeContractCollection"
>>>>
>>>> auto-retreive="true"
>>>> auto-update="true">
>>>> <inverse-foreignkey field-ref="employeeId"/>
>>>> </collection-descriptor>
>>>>
>>>> <collection-descriptor
>>>> name="employeeServiceDetails"
>>>> element-class-ref="com.hours28.domain.entity.EmployeeServiceDetail"
>>>> collection-class="com.hours28.domain.entity.EmployeeServiceDetailCollection"
>>>>
>>>> auto-retreive="true"
>>>> auto-update="true">
>>>> <inverse-foreignkey field-ref="employeeId"/>
>>>> </collection-descriptor>
>>>>
>>>> Are both classes EmployeeContractCollection,
>>>> EmployeeServiceDetailCollection instance of Collection?
>>>>
>>>> regards,
>>>> Armin
>>>>
>>>> Raymond Barlow wrote:
>>>>
>>>>
>>>>> Hi Armin,<snip>
>>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
--
*Reda BENZAIR**
*Software Analyst
***
*Phone: +33 (0)1 4996 6324
Fax: +33 (0)1 4996 6405
Mobile: +33 (0)6 6240 6192
reda.benzair@smartjog.com <ma...@smartjog.com>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: upgrade to RC5, ClassCastException on getCollectionByQuery
Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi Raymond,
Jakob has checked in a fix. Will be included
in the upcoming 1.0 version.
regards,
Armin
Armin Waibel wrote:
> Hi,
>
> rbarlow@raymanoz.com wrote:
>
>> Hi Armin,
>>
>> Ah, right yes, that would make sense. Those 2 classes are not
>> instances of
>> Collection. They descend from java.lang.Object (ie. does not extend
>> anything). The implement ManagableCollection.
>>
>> This worked for rc3, I guess there's been changes around that since. Does
>
>
> yes, I think the prefetching mechanism was added since rc3
>
>> this mean that I now need to descend all my custom list classes from
>> Collection?
>
>
> hmm, I don't implement this new part, but I assume it's a bug, because I
> can't find an note in the release-notes that now all collection-class
> need to be instance of collection. And this wouldn't be make sense
> because in repository.dtd we say
> "This attribute must only specified if the attribute type is not a
> java.util.Collection (or subclass) or Array type."
>
> I will try to add a test case for this problem.
>
> regards,
> Armin
>
>>
>> -Raymond
>>
>>
>>> Hi Raymond,
>>>
>>> the error occured in method prefetchRelationship(Collection owners)
>>> line 149 when a cast for the 1:n references is done.
>>> The cast is
>>>
>>> if (collectionClass != null)
>>> {
>>> newChildren = (Collection)
>>> broker.getCollectionByQuery(collectionClass, queries[i]); //Line 149
>>> }
>>>
>>> Thus I think OJB has problems with one of your collection class in
>>> class-descriptor of Employee
>>>
>>> <collection-descriptor
>>> name="contracts"
>>> element-class-ref="com.hours28.domain.entity.EmployeeContract"
>>> collection-class="com.hours28.domain.entity.EmployeeContractCollection"
>>> auto-retreive="true"
>>> auto-update="true">
>>> <inverse-foreignkey field-ref="employeeId"/>
>>> </collection-descriptor>
>>>
>>> <collection-descriptor
>>> name="employeeServiceDetails"
>>> element-class-ref="com.hours28.domain.entity.EmployeeServiceDetail"
>>> collection-class="com.hours28.domain.entity.EmployeeServiceDetailCollection"
>>>
>>> auto-retreive="true"
>>> auto-update="true">
>>> <inverse-foreignkey field-ref="employeeId"/>
>>> </collection-descriptor>
>>>
>>> Are both classes EmployeeContractCollection,
>>> EmployeeServiceDetailCollection instance of Collection?
>>>
>>> regards,
>>> Armin
>>>
>>> Raymond Barlow wrote:
>>>
>>>
>>>> Hi Armin,<snip>
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: upgrade to RC5, ClassCastException on getCollectionByQuery
Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi,
rbarlow@raymanoz.com wrote:
> Hi Armin,
>
> Ah, right yes, that would make sense. Those 2 classes are not instances of
> Collection. They descend from java.lang.Object (ie. does not extend
> anything). The implement ManagableCollection.
>
> This worked for rc3, I guess there's been changes around that since. Does
yes, I think the prefetching mechanism was added since rc3
> this mean that I now need to descend all my custom list classes from
> Collection?
hmm, I don't implement this new part, but I assume it's a bug, because I
can't find an note in the release-notes that now all collection-class
need to be instance of collection. And this wouldn't be make sense
because in repository.dtd we say
"This attribute must only specified if the attribute type is not a
java.util.Collection (or subclass) or Array type."
I will try to add a test case for this problem.
regards,
Armin
>
> -Raymond
>
>
>>Hi Raymond,
>>
>>the error occured in method prefetchRelationship(Collection owners)
>>line 149 when a cast for the 1:n references is done.
>>The cast is
>>
>>if (collectionClass != null)
>>{
>> newChildren = (Collection)
>>broker.getCollectionByQuery(collectionClass, queries[i]); //Line 149
>>}
>>
>>Thus I think OJB has problems with one of your collection class in
>>class-descriptor of Employee
>>
>><collection-descriptor
>> name="contracts"
>> element-class-ref="com.hours28.domain.entity.EmployeeContract"
>> collection-class="com.hours28.domain.entity.EmployeeContractCollection"
>> auto-retreive="true"
>> auto-update="true">
>> <inverse-foreignkey field-ref="employeeId"/>
>> </collection-descriptor>
>>
>> <collection-descriptor
>> name="employeeServiceDetails"
>>element-class-ref="com.hours28.domain.entity.EmployeeServiceDetail"
>>collection-class="com.hours28.domain.entity.EmployeeServiceDetailCollection"
>> auto-retreive="true"
>> auto-update="true">
>> <inverse-foreignkey field-ref="employeeId"/>
>> </collection-descriptor>
>>
>>Are both classes EmployeeContractCollection,
>>EmployeeServiceDetailCollection instance of Collection?
>>
>>regards,
>>Armin
>>
>>Raymond Barlow wrote:
>>
>>
>>>Hi Armin,<snip>
>
>
> ---------------------------------------------------------------------
> 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
Re: upgrade to RC5, ClassCastException on getCollectionByQuery
Posted by rb...@raymanoz.com.
Hi Armin,
Ah, right yes, that would make sense. Those 2 classes are not instances of
Collection. They descend from java.lang.Object (ie. does not extend
anything). The implement ManagableCollection.
This worked for rc3, I guess there's been changes around that since. Does
this mean that I now need to descend all my custom list classes from
Collection?
-Raymond
> Hi Raymond,
>
> the error occured in method prefetchRelationship(Collection owners)
> line 149 when a cast for the 1:n references is done.
> The cast is
>
> if (collectionClass != null)
> {
> newChildren = (Collection)
> broker.getCollectionByQuery(collectionClass, queries[i]); //Line 149
> }
>
> Thus I think OJB has problems with one of your collection class in
> class-descriptor of Employee
>
> <collection-descriptor
> name="contracts"
> element-class-ref="com.hours28.domain.entity.EmployeeContract"
> collection-class="com.hours28.domain.entity.EmployeeContractCollection"
> auto-retreive="true"
> auto-update="true">
> <inverse-foreignkey field-ref="employeeId"/>
> </collection-descriptor>
>
> <collection-descriptor
> name="employeeServiceDetails"
> element-class-ref="com.hours28.domain.entity.EmployeeServiceDetail"
> collection-class="com.hours28.domain.entity.EmployeeServiceDetailCollection"
> auto-retreive="true"
> auto-update="true">
> <inverse-foreignkey field-ref="employeeId"/>
> </collection-descriptor>
>
> Are both classes EmployeeContractCollection,
> EmployeeServiceDetailCollection instance of Collection?
>
> regards,
> Armin
>
> Raymond Barlow wrote:
>
>> Hi Armin,<snip>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: upgrade to RC5, ClassCastException on getCollectionByQuery
Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi Raymond,
the error occured in method prefetchRelationship(Collection owners)
line 149 when a cast for the 1:n references is done.
The cast is
if (collectionClass != null)
{
newChildren = (Collection)
broker.getCollectionByQuery(collectionClass, queries[i]); //Line 149
}
Thus I think OJB has problems with one of your collection class in
class-descriptor of Employee
<collection-descriptor
name="contracts"
element-class-ref="com.hours28.domain.entity.EmployeeContract"
collection-class="com.hours28.domain.entity.EmployeeContractCollection"
auto-retreive="true"
auto-update="true">
<inverse-foreignkey field-ref="employeeId"/>
</collection-descriptor>
<collection-descriptor
name="employeeServiceDetails"
element-class-ref="com.hours28.domain.entity.EmployeeServiceDetail"
collection-class="com.hours28.domain.entity.EmployeeServiceDetailCollection"
auto-retreive="true"
auto-update="true">
<inverse-foreignkey field-ref="employeeId"/>
</collection-descriptor>
Are both classes EmployeeContractCollection,
EmployeeServiceDetailCollection instance of Collection?
regards,
Armin
Raymond Barlow wrote:
> Hi Armin,
>
> Since my my lsat post, I've found that this is something to do with
> polymorphic classes/extents. I've basically got a base "User" class, and
> descendingt from that are 2 classes "Supplier" and "Employee". "User" is
> an abstract class, and the only "Supplier" and "Employee" are concrete
> classes. Thus, there is no table for "User". "Employee" and "Supplier"
> map to their own tables. I will recompile the jars, but until then, here
> are the class-descriptors for the 3 classes:
>
> <class-descriptor
> class="com.hours28.domain.entity.User">
> <extent-class class-ref="com.hours28.domain.entity.Employee"/>
> <extent-class class-ref="com.hours28.domain.entity.Supplier"/>
> </class-descriptor>
>
> <class-descriptor
> class="com.hours28.domain.entity.Employee"
> table="Employee">
> <field-descriptor
> name="oid"
> column="employeeId"
> jdbc-type="INTEGER"
> primarykey="true"
> autoincrement="true"/>
> <field-descriptor
> name="userName"
> column="userName"
> jdbc-type="VARCHAR"/>
> <field-descriptor
> name="password"
> column="password"
> jdbc-type="VARCHAR"/>
> <field-descriptor
> name="restricted"
> column="restricted"
> jdbc-type="BIT"/>
> <field-descriptor
> name="notes"
> column="notes"
> jdbc-type="VARCHAR"/>
> <field-descriptor
> name="imageStoredFileId"
> column="imageStoredFileId"
> jdbc-type="INTEGER"/>
> <reference-descriptor
> name="image"
> class-ref="com.hours28.domain.entity.StoredFile">
> <foreignkey field-ref="imageStoredFileId"/>
> </reference-descriptor>
> <field-descriptor
> name="securityLevelId"
> column="securityLevelId"
> jdbc-type="INTEGER"/>
> <reference-descriptor
> name="securityLevel"
> class-ref="com.hours28.domain.entity.SecurityLevel">
> <foreignkey field-ref="securityLevelId"/>
> </reference-descriptor>
> <collection-descriptor
> name="devices"
> element-class-ref="com.hours28.domain.entity.ContactDevice"
> auto-retrieve="true"
> auto-update="true"
> indirection-table="EmployeeContactDevice">
> <fk-pointing-to-this-class column="employeeId"/>
> <fk-pointing-to-element-class column="contactDeviceId"/>
> </collection-descriptor>
> <collection-descriptor
> name="addresses"
> element-class-ref="com.hours28.domain.entity.Address"
> auto-retrieve="true"
> auto-update="true"
> indirection-table="EmployeeAddress">
> <fk-pointing-to-this-class column="employeeId"/>
> <fk-pointing-to-element-class column="addressId"/>
> </collection-descriptor>
> <field-descriptor
> name="jobTitle"
> column="jobTitle"
> jdbc-type="VARCHAR"/>
> <field-descriptor
> name="startedWork"
> column="startedWork"
> jdbc-type="DATE"/>
> <field-descriptor
> name="title"
> column="title"
> jdbc-type="VARCHAR"/>
> <field-descriptor
> name="firstNames"
> column="firstNames"
> jdbc-type="VARCHAR"/>
> <field-descriptor
> name="lastName"
> column="lastName"
> jdbc-type="VARCHAR"/>
> <field-descriptor
> name="dateOfBirth"
> column="dateOfBirth"
> jdbc-type="DATE"/>
> <field-descriptor
> name="companyId"
> column="companyId"
> jdbc-type="INTEGER"
> access="anonymous"/>
> <reference-descriptor
> name="company"
> class-ref="com.hours28.domain.entity.Company">
> <foreignkey field-ref="companyId"/>
> </reference-descriptor>
> <field-descriptor
> name="interests"
> column="interests"
> jdbc-type="VARCHAR"/>
> <collection-descriptor
> name="contracts"
> element-class-ref="com.hours28.domain.entity.EmployeeContract"
>
> collection-class="com.hours28.domain.entity.EmployeeContractCollection"
> auto-retreive="true"
> auto-update="true">
> <inverse-foreignkey field-ref="employeeId"/>
> </collection-descriptor>
> <collection-descriptor
> name="employeeServiceDetails"
> element-class-ref="com.hours28.domain.entity.EmployeeServiceDetail"
>
> collection-class="com.hours28.domain.entity.EmployeeServiceDetailCollection"
>
> auto-retreive="true"
> auto-update="true">
> <inverse-foreignkey field-ref="employeeId"/>
> </collection-descriptor>
> </class-descriptor>
>
> <class-descriptor
> class="com.hours28.domain.entity.Supplier"
> table="Supplier">
> <field-descriptor
> name="oid"
> column="supplierId"
> jdbc-type="INTEGER"
> primarykey="true"
> autoincrement="true"/>
> <field-descriptor
> name="userName"
> column="userName"
> jdbc-type="VARCHAR"/>
> <field-descriptor
> name="password"
> column="password"
> jdbc-type="VARCHAR"/>
> <field-descriptor
> name="restricted"
> column="restricted"
> jdbc-type="BIT"/>
> <field-descriptor
> name="notes"
> column="notes"
> jdbc-type="VARCHAR"/>
> <field-descriptor
> name="imageStoredFileId"
> column="imageStoredFileId"
> jdbc-type="INTEGER"/>
> <reference-descriptor
> name="image"
> class-ref="com.hours28.domain.entity.StoredFile">
> <foreignkey field-ref="imageStoredFileId"/>
> </reference-descriptor>
> <field-descriptor
> name="securityLevelId"
> column="securityLevelId"
> jdbc-type="INTEGER"/>
> <reference-descriptor
> name="securityLevel"
> class-ref="com.hours28.domain.entity.SecurityLevel">
> <foreignkey field-ref="securityLevelId"/>
> </reference-descriptor>
> <collection-descriptor
> name="devices"
> element-class-ref="com.hours28.domain.entity.ContactDevice"
> auto-retrieve="true"
> auto-update="true"
> indirection-table="SupplierContactDevice">
> <fk-pointing-to-this-class column="supplierId"/>
> <fk-pointing-to-element-class column="contactDeviceId"/>
> </collection-descriptor>
> <collection-descriptor
> name="addresses"
> element-class-ref="com.hours28.domain.entity.Address"
> auto-retrieve="true"
> auto-update="true"
> indirection-table="SupplierAddress">
> <fk-pointing-to-this-class column="supplierId"/>
> <fk-pointing-to-element-class column="addressId"/>
> </collection-descriptor>
> <field-descriptor
> name="name"
> column="name"
> jdbc-type="VARCHAR"/>
> <field-descriptor
> name="forReal"
> column="forReal"
> jdbc-type="BIT"/>
> <field-descriptor
> name="preferredBookingDeviceId"
> column="preferredBookingDeviceId"
> jdbc-type="INTEGER"
> access="anonymous"/>
> <reference-descriptor
> name="preferredBookingDevice"
> class-ref="com.hours28.domain.entity.ContactDevice">
> <foreignkey field-ref="preferredBookingDeviceId"/>
> </reference-descriptor>
> <field-descriptor
> name="abn"
> column="abn"
> jdbc-type="VARCHAR"/>
> <field-descriptor
> name="acn"
> column="acn"
> jdbc-type="VARCHAR"/>
> <field-descriptor
> name="beganBusiness"
> column="beganBusiness"
> jdbc-type="DATE"/>
> <field-descriptor
> name="description"
> column="description"
> jdbc-type="VARCHAR"/>
> </class-descriptor>
>
> It has something to
>
> Armin Waibel 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
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: upgrade to RC5, ClassCastException on getCollectionByQuery
Posted by Raymond Barlow <rb...@raymanoz.com>.
Hi Armin,
Since my my lsat post, I've found that this is something to do with
polymorphic classes/extents. I've basically got a base "User" class, and
descendingt from that are 2 classes "Supplier" and "Employee". "User" is
an abstract class, and the only "Supplier" and "Employee" are concrete
classes. Thus, there is no table for "User". "Employee" and "Supplier"
map to their own tables. I will recompile the jars, but until then, here
are the class-descriptors for the 3 classes:
<class-descriptor
class="com.hours28.domain.entity.User">
<extent-class class-ref="com.hours28.domain.entity.Employee"/>
<extent-class class-ref="com.hours28.domain.entity.Supplier"/>
</class-descriptor>
<class-descriptor
class="com.hours28.domain.entity.Employee"
table="Employee">
<field-descriptor
name="oid"
column="employeeId"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"/>
<field-descriptor
name="userName"
column="userName"
jdbc-type="VARCHAR"/>
<field-descriptor
name="password"
column="password"
jdbc-type="VARCHAR"/>
<field-descriptor
name="restricted"
column="restricted"
jdbc-type="BIT"/>
<field-descriptor
name="notes"
column="notes"
jdbc-type="VARCHAR"/>
<field-descriptor
name="imageStoredFileId"
column="imageStoredFileId"
jdbc-type="INTEGER"/>
<reference-descriptor
name="image"
class-ref="com.hours28.domain.entity.StoredFile">
<foreignkey field-ref="imageStoredFileId"/>
</reference-descriptor>
<field-descriptor
name="securityLevelId"
column="securityLevelId"
jdbc-type="INTEGER"/>
<reference-descriptor
name="securityLevel"
class-ref="com.hours28.domain.entity.SecurityLevel">
<foreignkey field-ref="securityLevelId"/>
</reference-descriptor>
<collection-descriptor
name="devices"
element-class-ref="com.hours28.domain.entity.ContactDevice"
auto-retrieve="true"
auto-update="true"
indirection-table="EmployeeContactDevice">
<fk-pointing-to-this-class column="employeeId"/>
<fk-pointing-to-element-class column="contactDeviceId"/>
</collection-descriptor>
<collection-descriptor
name="addresses"
element-class-ref="com.hours28.domain.entity.Address"
auto-retrieve="true"
auto-update="true"
indirection-table="EmployeeAddress">
<fk-pointing-to-this-class column="employeeId"/>
<fk-pointing-to-element-class column="addressId"/>
</collection-descriptor>
<field-descriptor
name="jobTitle"
column="jobTitle"
jdbc-type="VARCHAR"/>
<field-descriptor
name="startedWork"
column="startedWork"
jdbc-type="DATE"/>
<field-descriptor
name="title"
column="title"
jdbc-type="VARCHAR"/>
<field-descriptor
name="firstNames"
column="firstNames"
jdbc-type="VARCHAR"/>
<field-descriptor
name="lastName"
column="lastName"
jdbc-type="VARCHAR"/>
<field-descriptor
name="dateOfBirth"
column="dateOfBirth"
jdbc-type="DATE"/>
<field-descriptor
name="companyId"
column="companyId"
jdbc-type="INTEGER"
access="anonymous"/>
<reference-descriptor
name="company"
class-ref="com.hours28.domain.entity.Company">
<foreignkey field-ref="companyId"/>
</reference-descriptor>
<field-descriptor
name="interests"
column="interests"
jdbc-type="VARCHAR"/>
<collection-descriptor
name="contracts"
element-class-ref="com.hours28.domain.entity.EmployeeContract"
collection-class="com.hours28.domain.entity.EmployeeContractCollection"
auto-retreive="true"
auto-update="true">
<inverse-foreignkey field-ref="employeeId"/>
</collection-descriptor>
<collection-descriptor
name="employeeServiceDetails"
element-class-ref="com.hours28.domain.entity.EmployeeServiceDetail"
collection-class="com.hours28.domain.entity.EmployeeServiceDetailCollection"
auto-retreive="true"
auto-update="true">
<inverse-foreignkey field-ref="employeeId"/>
</collection-descriptor>
</class-descriptor>
<class-descriptor
class="com.hours28.domain.entity.Supplier"
table="Supplier">
<field-descriptor
name="oid"
column="supplierId"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"/>
<field-descriptor
name="userName"
column="userName"
jdbc-type="VARCHAR"/>
<field-descriptor
name="password"
column="password"
jdbc-type="VARCHAR"/>
<field-descriptor
name="restricted"
column="restricted"
jdbc-type="BIT"/>
<field-descriptor
name="notes"
column="notes"
jdbc-type="VARCHAR"/>
<field-descriptor
name="imageStoredFileId"
column="imageStoredFileId"
jdbc-type="INTEGER"/>
<reference-descriptor
name="image"
class-ref="com.hours28.domain.entity.StoredFile">
<foreignkey field-ref="imageStoredFileId"/>
</reference-descriptor>
<field-descriptor
name="securityLevelId"
column="securityLevelId"
jdbc-type="INTEGER"/>
<reference-descriptor
name="securityLevel"
class-ref="com.hours28.domain.entity.SecurityLevel">
<foreignkey field-ref="securityLevelId"/>
</reference-descriptor>
<collection-descriptor
name="devices"
element-class-ref="com.hours28.domain.entity.ContactDevice"
auto-retrieve="true"
auto-update="true"
indirection-table="SupplierContactDevice">
<fk-pointing-to-this-class column="supplierId"/>
<fk-pointing-to-element-class column="contactDeviceId"/>
</collection-descriptor>
<collection-descriptor
name="addresses"
element-class-ref="com.hours28.domain.entity.Address"
auto-retrieve="true"
auto-update="true"
indirection-table="SupplierAddress">
<fk-pointing-to-this-class column="supplierId"/>
<fk-pointing-to-element-class column="addressId"/>
</collection-descriptor>
<field-descriptor
name="name"
column="name"
jdbc-type="VARCHAR"/>
<field-descriptor
name="forReal"
column="forReal"
jdbc-type="BIT"/>
<field-descriptor
name="preferredBookingDeviceId"
column="preferredBookingDeviceId"
jdbc-type="INTEGER"
access="anonymous"/>
<reference-descriptor
name="preferredBookingDevice"
class-ref="com.hours28.domain.entity.ContactDevice">
<foreignkey field-ref="preferredBookingDeviceId"/>
</reference-descriptor>
<field-descriptor
name="abn"
column="abn"
jdbc-type="VARCHAR"/>
<field-descriptor
name="acn"
column="acn"
jdbc-type="VARCHAR"/>
<field-descriptor
name="beganBusiness"
column="beganBusiness"
jdbc-type="DATE"/>
<field-descriptor
name="description"
column="description"
jdbc-type="VARCHAR"/>
</class-descriptor>
It has something to
Armin Waibel 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
>
>
--
Regards,
Raymond Barlow
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Calling custom store procedures in OJB
Posted by Suma Venkatesh <su...@yahoo.com>.
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
RE: Calling custom store procedures in OJB
Posted by Ron Gallagher <ro...@bellsouth.net>.
Suma --
At this point, OJB's support for stored procedures is limited to just data
persistence operations (insert, update or delete). Data retrieval (i.e.
select) is still performed by 'basic' sql statements. I am aware of no
plans at this time to extend SP support to handle data retrieval.
Ron Gallagher
Atlanta, GA
rongallagher@belsouth.net
-----Original Message-----
From: Suma Venkatesh [mailto:sumav_99@yahoo.com]
Sent: Sunday, January 11, 2004 6:07 PM
To: OJB Users List
Subject: 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
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Calling custom store procedures in OJB
Posted by Suma Venkatesh <su...@yahoo.com>.
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
Re: upgrade to RC5, ClassCastException on getCollectionByQuery
Posted by Armin Waibel <ar...@code-au-lait.de>.
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