You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by br...@apache.org on 2003/12/13 12:59:02 UTC
cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer BasePrefetcher.java CollectionPrefetcher.java
brj 2003/12/13 03:59:02
Modified: src/java/org/apache/ojb/broker/accesslayer
BasePrefetcher.java CollectionPrefetcher.java
Log:
- fixed prefetch bug (wrong cld used)
- minor refactorings, javadoc updates
Revision Changes Path
1.3 +27 -11 db-ojb/src/java/org/apache/ojb/broker/accesslayer/BasePrefetcher.java
Index: BasePrefetcher.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/BasePrefetcher.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BasePrefetcher.java 7 Nov 2003 21:45:48 -0000 1.2
+++ BasePrefetcher.java 13 Dec 2003 11:59:02 -0000 1.3
@@ -162,29 +162,45 @@
return buildPrefetchQuery(getItemClassDescriptor().getClassOfObject(), ids, fields);
}
- protected QueryByCriteria buildPrefetchQuery(Class clazz, Collection ids, FieldDescriptor[] fields)
+
+ /**
+ *
+ * @param ids collection of identities
+ * @param fields
+ * @return
+ */
+ protected Criteria buildPrefetchCriteria(Collection ids, FieldDescriptor[] fields)
{
- Criteria crit;
-
if (fields.length == 1)
{
- crit = buildPrefetchCriteriaSingleKey(ids, fields[0]);
+ return buildPrefetchCriteriaSingleKey(ids, fields[0]);
}
else
{
- crit = buildPrefetchCriteriaMultipleKeys(ids, fields);
+ return buildPrefetchCriteriaMultipleKeys(ids, fields);
}
-
- return QueryFactory.newQuery(clazz, crit);
+
+ }
+
+ /**
+ *
+ * @param clazz
+ * @param ids collection of identities
+ * @param fields
+ * @return
+ */
+ protected QueryByCriteria buildPrefetchQuery(Class clazz, Collection ids, FieldDescriptor[] fields)
+ {
+ return QueryFactory.newQuery(clazz, buildPrefetchCriteria(ids, fields));
}
/**
* Build the Criteria using IN(...) for single keys
- * @param ids
+ * @param ids collection of identities
* @param pkField
* @return Criteria
*/
- protected Criteria buildPrefetchCriteriaSingleKey(Collection ids, FieldDescriptor field)
+ private Criteria buildPrefetchCriteriaSingleKey(Collection ids, FieldDescriptor field)
{
Criteria crit = new Criteria();
ArrayList values = new ArrayList();
@@ -215,7 +231,7 @@
/**
* Build the Criteria using multiple ORs
- * @param ids
+ * @param ids collection of identities
* @param pkFields
* @return Criteria
*/
1.19 +26 -25 db-ojb/src/java/org/apache/ojb/broker/accesslayer/CollectionPrefetcher.java
Index: CollectionPrefetcher.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/CollectionPrefetcher.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- CollectionPrefetcher.java 28 Nov 2003 14:40:00 -0000 1.18
+++ CollectionPrefetcher.java 13 Dec 2003 11:59:02 -0000 1.19
@@ -61,7 +61,6 @@
import java.util.HashSet;
import java.util.Iterator;
-
import org.apache.ojb.broker.Identity;
import org.apache.ojb.broker.ManageableCollection;
import org.apache.ojb.broker.OJBRuntimeException;
@@ -78,27 +77,29 @@
/**
* Relationship Prefetcher for Collections.
- *
- * @author <a href="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a>
+ *
+ * @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
* @version $Id$
*/
public class CollectionPrefetcher extends RelationshipPrefetcherImpl
{
/**
- * Constructor for CollectionPrefetcher.
- * @param aBroker
- * @param anOrd
- */
+ * Constructor for CollectionPrefetcher.
+ *
+ * @param aBroker
+ * @param anOrd
+ */
public CollectionPrefetcher(PersistenceBroker aBroker, ObjectReferenceDescriptor anOrd)
{
super(aBroker, anOrd);
}
/**
- * Build the multiple queries for one relationship because of limitation of IN(...)
- * @param owners Collection containing all objects of the ONE side
- */
+ * Build the multiple queries for one relationship because of limitation of IN(...)
+ *
+ * @param owners Collection containing all objects of the ONE side
+ */
protected Query[] buildPrefetchQueries(Collection owners, Collection children)
{
ClassDescriptor cld = getOwnerClassDescriptor();
@@ -133,10 +134,10 @@
}
/**
- * Build the query to perform a batched read get orderBy settings from
- * CollectionDescriptor
- * @param ids Collection containing all identities of objects of the ONE side
- */
+ * Build the query to perform a batched read get orderBy settings from CollectionDescriptor
+ *
+ * @param ids Collection containing all identities of objects of the ONE side
+ */
protected Query buildPrefetchQuery(Collection ids)
{
CollectionDescriptor cds = getCollectionDescriptor();
@@ -156,18 +157,16 @@
}
/**
- * associate the batched Children with their owner object <br>
- * loop over children
- */
+ * associate the batched Children with their owner object loop over children
+ */
protected void associateBatched(Collection owners, Collection children)
{
CollectionDescriptor cds = getCollectionDescriptor();
- ClassDescriptor cld = getItemClassDescriptor();
+ ClassDescriptor cld;
PersistentField field = cds.getPersistentField();
PersistenceBroker pb = getBroker();
- Class ownerTopLevelClass = pb.getTopLevelClass(getOwnerClassDescriptor().getClassOfObject());
- // this collection type will be used:
- Class collectionClass = cds.getCollectionClass();
+ Class ownerTopLevelClass = pb.getTopLevelClass(getOwnerClassDescriptor().getClassOfObject());
+ Class collectionClass = cds.getCollectionClass(); // this collection type will be used:
Object owner, relatedObject;
Object fkValues[];
Identity id;
@@ -175,9 +174,11 @@
ArrayList list;
Object result;
- for (Iterator it = children.iterator(); it.hasNext(); )
+ for (Iterator it = children.iterator(); it.hasNext();)
{
relatedObject = it.next();
+ // BRJ: use cld of real class
+ cld = getDescriptorRepository().getDescriptorFor(relatedObject.getClass());
fkValues = cds.getForeignKeyValues(relatedObject, cld);
id = new Identity(null, ownerTopLevelClass, fkValues);
list = (ArrayList) ownerIdsToLists.get(id);
@@ -189,7 +190,7 @@
list.add(relatedObject);
}
- for (Iterator it = owners.iterator(); it.hasNext(); )
+ for (Iterator it = owners.iterator(); it.hasNext();)
{
owner = it.next();
id = new Identity(owner, pb);
@@ -227,7 +228,7 @@
throw new OJBRuntimeException("Can't create new Collection for owner", e);
}
}
- for (Iterator it2 = list.iterator(); it2.hasNext(); )
+ for (Iterator it2 = list.iterator(); it2.hasNext();)
{
col.ojbAdd(it2.next());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
Re: cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer
BasePrefetcher.java CollectionPrefetcher.java
Posted by Armin Waibel <ar...@code-au-lait.de>.
>
> Do you also get this errors, or is it a local problem for me only?
>
> cu,
> Thomas
I can confirm the errors.
switching back CollectionPrefetcher and
BasePrefetcher to previous version no errors occur (only 2 failures)
Armin
Thomas Mahler wrote:
> Hi Jakob,
>
> thanks for the quick fix. Unfortunately you changes cause a problem with
> dynamic proxies. I get five junit errors after checking out your changes.
>
> here is an example:
>
> testInversePathExpression
> Error
> org.apache.ojb.broker.PersistenceBrokerException:
> org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException:
> $Proxy0 not found in OJB Repository
>
> org.apache.ojb.broker.PersistenceBrokerException:
> org.apache.ojb.broker.PersistenceBrokerException:
> org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException:
> $Proxy0 not found in OJB Repository
> at
> org.apache.ojb.broker.accesslayer.IndirectionHandler.materializeSubject(IndirectionHandler.java:345)
>
> at
> org.apache.ojb.broker.accesslayer.IndirectionHandler.getRealSubject(IndirectionHandler.java:309)
>
> at
> org.apache.ojb.broker.VirtualProxy.getRealSubject(VirtualProxy.java:152)
> at
> org.apache.ojb.broker.QueryTest.testInversePathExpression(QueryTest.java:494)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>
> Caused by: org.apache.ojb.broker.PersistenceBrokerException:
> org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException:
> $Proxy0 not found in OJB Repository
> 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.accesslayer.BasePrefetcher.prefetchRelationship(BasePrefetcher.java:153)
>
> at
> org.apache.ojb.broker.core.QueryReferenceBroker$PBPrefetchingListener.prefetch(QueryReferenceBroker.java:835)
>
> at
> org.apache.ojb.broker.core.QueryReferenceBroker$PBMaterializationListener.beforeMaterialization(QueryReferenceBroker.java:772)
>
> at
> org.apache.ojb.broker.accesslayer.IndirectionHandler.beforeMaterialization(IndirectionHandler.java:146)
>
> at
> org.apache.ojb.broker.accesslayer.IndirectionHandler.materializeSubject(IndirectionHandler.java:332)
>
>
>
> Do you also get this errors, or is it a local problem for me only?
>
> cu,
> Thomas
>
>
>
>
> brj@apache.org wrote:
>
>> brj 2003/12/13 03:59:02
>>
>> Modified: src/java/org/apache/ojb/broker/accesslayer
>> BasePrefetcher.java CollectionPrefetcher.java
>> Log:
>> - fixed prefetch bug (wrong cld used) - minor refactorings,
>> javadoc updates
>> Revision Changes Path
>> 1.3 +27 -11
>> db-ojb/src/java/org/apache/ojb/broker/accesslayer/BasePrefetcher.java
>> Index: BasePrefetcher.java
>> ===================================================================
>> RCS file:
>> /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/BasePrefetcher.java,v
>>
>> retrieving revision 1.2
>> retrieving revision 1.3
>> diff -u -r1.2 -r1.3
>> --- BasePrefetcher.java 7 Nov 2003 21:45:48 -0000 1.2
>> +++ BasePrefetcher.java 13 Dec 2003 11:59:02 -0000 1.3
>> @@ -162,29 +162,45 @@
>> return
>> buildPrefetchQuery(getItemClassDescriptor().getClassOfObject(), ids,
>> fields);
>> }
>> - protected QueryByCriteria buildPrefetchQuery(Class clazz,
>> Collection ids, FieldDescriptor[] fields)
>> + + /**
>> + * + * @param ids collection of identities
>> + * @param fields
>> + * @return
>> + */
>> + protected Criteria buildPrefetchCriteria(Collection ids,
>> FieldDescriptor[] fields)
>> {
>> - Criteria crit;
>> -
>> if (fields.length == 1)
>> {
>> - crit = buildPrefetchCriteriaSingleKey(ids, fields[0]);
>> + return buildPrefetchCriteriaSingleKey(ids, fields[0]);
>> }
>> else
>> {
>> - crit = buildPrefetchCriteriaMultipleKeys(ids, fields);
>> + return buildPrefetchCriteriaMultipleKeys(ids, fields);
>> }
>> -
>> - return QueryFactory.newQuery(clazz, crit);
>> + + }
>> + + /**
>> + * + * @param clazz
>> + * @param ids collection of identities
>> + * @param fields
>> + * @return
>> + */
>> + protected QueryByCriteria buildPrefetchQuery(Class clazz,
>> Collection ids, FieldDescriptor[] fields)
>> + {
>> + return QueryFactory.newQuery(clazz,
>> buildPrefetchCriteria(ids, fields));
>> }
>> /**
>> * Build the Criteria using IN(...) for single keys
>> - * @param ids
>> + * @param ids collection of identities
>> * @param pkField
>> * @return Criteria
>> */
>> - protected Criteria buildPrefetchCriteriaSingleKey(Collection
>> ids, FieldDescriptor field)
>> + private Criteria buildPrefetchCriteriaSingleKey(Collection ids,
>> FieldDescriptor field)
>> {
>> Criteria crit = new Criteria();
>> ArrayList values = new ArrayList();
>> @@ -215,7 +231,7 @@
>> /**
>> * Build the Criteria using multiple ORs
>> - * @param ids
>> + * @param ids collection of identities
>> * @param pkFields
>> * @return Criteria
>> */
>> 1.19 +26 -25
>> db-ojb/src/java/org/apache/ojb/broker/accesslayer/CollectionPrefetcher.java
>>
>> Index: CollectionPrefetcher.java
>> ===================================================================
>> RCS file:
>> /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/CollectionPrefetcher.java,v
>>
>> retrieving revision 1.18
>> retrieving revision 1.19
>> diff -u -r1.18 -r1.19
>> --- CollectionPrefetcher.java 28 Nov 2003 14:40:00 -0000 1.18
>> +++ CollectionPrefetcher.java 13 Dec 2003 11:59:02 -0000 1.19
>> @@ -61,7 +61,6 @@
>> import java.util.HashSet;
>> import java.util.Iterator;
>> -
>> import org.apache.ojb.broker.Identity;
>> import org.apache.ojb.broker.ManageableCollection;
>> import org.apache.ojb.broker.OJBRuntimeException;
>> @@ -78,27 +77,29 @@
>> /**
>> * Relationship Prefetcher for Collections.
>> - *
>> - * @author <a href="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a>
>> + * + * @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
>> * @version $Id$
>> */
>> public class CollectionPrefetcher extends RelationshipPrefetcherImpl
>> {
>> /**
>> - * Constructor for CollectionPrefetcher.
>> - * @param aBroker
>> - * @param anOrd
>> - */
>> + * Constructor for CollectionPrefetcher.
>> + * + * @param aBroker
>> + * @param anOrd
>> + */
>> public CollectionPrefetcher(PersistenceBroker aBroker,
>> ObjectReferenceDescriptor anOrd)
>> {
>> super(aBroker, anOrd);
>> }
>> /**
>> - * Build the multiple queries for one relationship because of
>> limitation of IN(...)
>> - * @param owners Collection containing all objects of the ONE side
>> - */
>> + * Build the multiple queries for one relationship because of
>> limitation of IN(...)
>> + * + * @param owners Collection containing all objects of
>> the ONE side
>> + */
>> protected Query[] buildPrefetchQueries(Collection owners,
>> Collection children)
>> {
>> ClassDescriptor cld = getOwnerClassDescriptor();
>> @@ -133,10 +134,10 @@
>> }
>> /**
>> - * Build the query to perform a batched read get orderBy
>> settings from
>> - * CollectionDescriptor
>> - * @param ids Collection containing all identities of objects
>> of the ONE side
>> - */
>> + * Build the query to perform a batched read get orderBy
>> settings from CollectionDescriptor
>> + * + * @param ids Collection containing all identities of
>> objects of the ONE side
>> + */
>> protected Query buildPrefetchQuery(Collection ids)
>> {
>> CollectionDescriptor cds = getCollectionDescriptor();
>> @@ -156,18 +157,16 @@
>> }
>> /**
>> - * associate the batched Children with their owner object <br>
>> - * loop over children
>> - */
>> + * associate the batched Children with their owner object loop
>> over children
>> + */ protected void associateBatched(Collection owners,
>> Collection children)
>> {
>> CollectionDescriptor cds = getCollectionDescriptor();
>> - ClassDescriptor cld = getItemClassDescriptor();
>> + ClassDescriptor cld;
>> PersistentField field = cds.getPersistentField();
>> PersistenceBroker pb = getBroker();
>> - Class ownerTopLevelClass =
>> pb.getTopLevelClass(getOwnerClassDescriptor().getClassOfObject());
>> - // this collection type will be used:
>> - Class collectionClass = cds.getCollectionClass();
>> + Class ownerTopLevelClass =
>> pb.getTopLevelClass(getOwnerClassDescriptor().getClassOfObject());
>> + Class collectionClass = cds.getCollectionClass(); // this
>> collection type will be used:
>> Object owner, relatedObject;
>> Object fkValues[];
>> Identity id;
>> @@ -175,9 +174,11 @@
>> ArrayList list;
>> Object result;
>> - for (Iterator it = children.iterator(); it.hasNext(); )
>> + for (Iterator it = children.iterator(); it.hasNext();)
>> {
>> relatedObject = it.next();
>> + // BRJ: use cld of real class
>> + cld =
>> getDescriptorRepository().getDescriptorFor(relatedObject.getClass());
>> fkValues = cds.getForeignKeyValues(relatedObject, cld);
>> id = new Identity(null, ownerTopLevelClass, fkValues);
>> list = (ArrayList) ownerIdsToLists.get(id);
>> @@ -189,7 +190,7 @@
>> list.add(relatedObject);
>> }
>> - for (Iterator it = owners.iterator(); it.hasNext(); )
>> + for (Iterator it = owners.iterator(); it.hasNext();)
>> {
>> owner = it.next();
>> id = new Identity(owner, pb);
>> @@ -227,7 +228,7 @@
>> throw new OJBRuntimeException("Can't create
>> new Collection for owner", e);
>> }
>> }
>> - for (Iterator it2 = list.iterator(); it2.hasNext(); )
>> + for (Iterator it2 = list.iterator(); it2.hasNext();)
>> {
>> col.ojbAdd(it2.next());
>> }
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
Re: cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer BasePrefetcher.java CollectionPrefetcher.java
Posted by Oleg Nitz <on...@ukr.net>.
On Saturday 13 December 2003 12:21, Thomas Mahler wrote:
> thanks for the quick fix. Unfortunately you changes cause a problem with
> dynamic proxies. I get five junit errors after checking out your changes.
Looks like the problem is with auto-prefetching: there shouldn't be any
proxies in the prefetched collection. I am going to investigate this
situation.
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
Re: cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer
BasePrefetcher.java CollectionPrefetcher.java
Posted by Thomas Mahler <th...@web.de>.
Hi Oleg,
thanks for the quick patch!
Unfortunately it resulted in three failures in the ODMG tests. could you
please recheck your changes?
thanks,
thomas
Oleg Nitz wrote:
> On Saturday 13 December 2003 12:21, Thomas Mahler wrote:
>
>>thanks for the quick fix. Unfortunately you changes cause a problem with
>> dynamic proxies. I get five junit errors after checking out your changes.
>
> Fixed!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
Re: cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer
BasePrefetcher.java CollectionPrefetcher.java
Posted by Thomas Mahler <th...@web.de>.
Hi Oleg,
sorry to be such a PITA.
But I still get the same 3 failures with ODMG and still have the error
in testPrefechedArraySingleKey.
I did not see any new check ins from you. (The latest I see was the
getObjectByQuery in PBImpl.
Maybe you did not check in everything?
cheers,
Thomas
Oleg Nitz wrote:
> On Saturday 13 December 2003 12:21, Thomas Mahler wrote:
>
>>thanks for the quick fix. Unfortunately you changes cause a problem with
>> dynamic proxies. I get five junit errors after checking out your changes.
>
> Fixed!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
Re: [junit] Still get junit errors
Posted by Oleg Nitz <on...@ukr.net>.
Sorry, that was stupid error in my fix :(
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
Re: [junit] Still get junit errors
Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi all,
the test can be forced to pass by adding
q.addPrefetchedRelationship("allArticlesInGroup");
this forces the relationship to be loaded. but this is imo not the right
way to do it :(
jakob
Jakob Braeuchi wrote:
> hi all,
>
> i get an error in QueryTest#testPrefetchedArraySingleKey. Array of
> articles is null when the using the proxy
>
> ...
> //
> // use ProductGroupWithArray and Articles with original Proxy settings
> //
> broker.clearCache();
> cldArticle.setProxyClass(articleProxy);
>
> crit = new Criteria();
> crit.addEqualTo("groupId", new Integer(5));
> q = QueryFactory.newQuery(ProductGroupWithArray.class, crit);
> results = broker.getCollectionByQuery(q);
> ProductGroupWithArray pg2 = (ProductGroupWithArray)results.toArray()[0];
> InterfaceArticle[] articles = pg2.getAllArticles();
> _assertNotNull_("Array of articles should not be null!", articles);
> assertTrue("Array should contain more than 0 entries!",articles.length
> != 0);
> ...
>
>
> this is due to QueryReferenceBroker#performRetrievalTasks
>
> ...
> if (ord.isLazy() || (_ord.getItemProxyClass() != null_))
> {
> continue;
> }
> ...
>
>
> jakob
>
> Armin Waibel wrote:
>
>> Hi Oleg,
>>
>> I still get
>>
>> 1 errors (+ one known failure) in PB
>> 3 failures in ODMG
>>
>> when running the test suite.
>>
>> What's wrong?
>>
>> regards,
>> Armin
>>
>> Oleg Nitz wrote:
>>
>>> On Saturday 13 December 2003 12:21, Thomas Mahler wrote:
>>>
>>>> thanks for the quick fix. Unfortunately you changes cause a problem
>>>> with
>>>> dynamic proxies. I get five junit errors after checking out your
>>>> changes.
>>>
>>>
>>>
>>> Fixed!
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>>>
>>>
>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
Re: [junit] Still get junit errors
Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi all,
i get an error in QueryTest#testPrefetchedArraySingleKey. Array of
articles is null when the using the proxy
...
//
// use ProductGroupWithArray and Articles with original Proxy settings
//
broker.clearCache();
cldArticle.setProxyClass(articleProxy);
crit = new Criteria();
crit.addEqualTo("groupId", new Integer(5));
q = QueryFactory.newQuery(ProductGroupWithArray.class, crit);
results = broker.getCollectionByQuery(q);
ProductGroupWithArray pg2 = (ProductGroupWithArray)results.toArray()[0];
InterfaceArticle[] articles = pg2.getAllArticles();
_assertNotNull_("Array of articles should not be null!", articles);
assertTrue("Array should contain more than 0 entries!",articles.length
!= 0);
...
this is due to QueryReferenceBroker#performRetrievalTasks
...
if (ord.isLazy() || (_ord.getItemProxyClass() != null_))
{
continue;
}
...
jakob
Armin Waibel wrote:
> Hi Oleg,
>
> I still get
>
> 1 errors (+ one known failure) in PB
> 3 failures in ODMG
>
> when running the test suite.
>
> What's wrong?
>
> regards,
> Armin
>
> Oleg Nitz wrote:
>
>> On Saturday 13 December 2003 12:21, Thomas Mahler wrote:
>>
>>> thanks for the quick fix. Unfortunately you changes cause a problem with
>>> dynamic proxies. I get five junit errors after checking out your
>>> changes.
>>
>>
>> Fixed!
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>>
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
[junit] Still get junit errors
Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi Oleg,
I still get
1 errors (+ one known failure) in PB
3 failures in ODMG
when running the test suite.
What's wrong?
regards,
Armin
Oleg Nitz wrote:
> On Saturday 13 December 2003 12:21, Thomas Mahler wrote:
>
>>thanks for the quick fix. Unfortunately you changes cause a problem with
>> dynamic proxies. I get five junit errors after checking out your changes.
>
> Fixed!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
Re: cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer BasePrefetcher.java CollectionPrefetcher.java
Posted by Oleg Nitz <on...@ukr.net>.
On Saturday 13 December 2003 12:21, Thomas Mahler wrote:
> thanks for the quick fix. Unfortunately you changes cause a problem with
> dynamic proxies. I get five junit errors after checking out your changes.
Fixed!
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
Re: cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer
BasePrefetcher.java CollectionPrefetcher.java
Posted by Thomas Mahler <th...@web.de>.
Hi Jakob,
thanks for the quick fix. Unfortunately you changes cause a problem with
dynamic proxies. I get five junit errors after checking out your changes.
here is an example:
testInversePathExpression
Error
org.apache.ojb.broker.PersistenceBrokerException:
org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException:
$Proxy0 not found in OJB Repository
org.apache.ojb.broker.PersistenceBrokerException:
org.apache.ojb.broker.PersistenceBrokerException:
org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException:
$Proxy0 not found in OJB Repository
at
org.apache.ojb.broker.accesslayer.IndirectionHandler.materializeSubject(IndirectionHandler.java:345)
at
org.apache.ojb.broker.accesslayer.IndirectionHandler.getRealSubject(IndirectionHandler.java:309)
at
org.apache.ojb.broker.VirtualProxy.getRealSubject(VirtualProxy.java:152)
at
org.apache.ojb.broker.QueryTest.testInversePathExpression(QueryTest.java:494)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Caused by: org.apache.ojb.broker.PersistenceBrokerException:
org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException:
$Proxy0 not found in OJB Repository
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.accesslayer.BasePrefetcher.prefetchRelationship(BasePrefetcher.java:153)
at
org.apache.ojb.broker.core.QueryReferenceBroker$PBPrefetchingListener.prefetch(QueryReferenceBroker.java:835)
at
org.apache.ojb.broker.core.QueryReferenceBroker$PBMaterializationListener.beforeMaterialization(QueryReferenceBroker.java:772)
at
org.apache.ojb.broker.accesslayer.IndirectionHandler.beforeMaterialization(IndirectionHandler.java:146)
at
org.apache.ojb.broker.accesslayer.IndirectionHandler.materializeSubject(IndirectionHandler.java:332)
Do you also get this errors, or is it a local problem for me only?
cu,
Thomas
brj@apache.org wrote:
> brj 2003/12/13 03:59:02
>
> Modified: src/java/org/apache/ojb/broker/accesslayer
> BasePrefetcher.java CollectionPrefetcher.java
> Log:
> - fixed prefetch bug (wrong cld used)
> - minor refactorings, javadoc updates
>
> Revision Changes Path
> 1.3 +27 -11 db-ojb/src/java/org/apache/ojb/broker/accesslayer/BasePrefetcher.java
>
> Index: BasePrefetcher.java
> ===================================================================
> RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/BasePrefetcher.java,v
> retrieving revision 1.2
> retrieving revision 1.3
> diff -u -r1.2 -r1.3
> --- BasePrefetcher.java 7 Nov 2003 21:45:48 -0000 1.2
> +++ BasePrefetcher.java 13 Dec 2003 11:59:02 -0000 1.3
> @@ -162,29 +162,45 @@
> return buildPrefetchQuery(getItemClassDescriptor().getClassOfObject(), ids, fields);
> }
>
> - protected QueryByCriteria buildPrefetchQuery(Class clazz, Collection ids, FieldDescriptor[] fields)
> +
> + /**
> + *
> + * @param ids collection of identities
> + * @param fields
> + * @return
> + */
> + protected Criteria buildPrefetchCriteria(Collection ids, FieldDescriptor[] fields)
> {
> - Criteria crit;
> -
> if (fields.length == 1)
> {
> - crit = buildPrefetchCriteriaSingleKey(ids, fields[0]);
> + return buildPrefetchCriteriaSingleKey(ids, fields[0]);
> }
> else
> {
> - crit = buildPrefetchCriteriaMultipleKeys(ids, fields);
> + return buildPrefetchCriteriaMultipleKeys(ids, fields);
> }
> -
> - return QueryFactory.newQuery(clazz, crit);
> +
> + }
> +
> + /**
> + *
> + * @param clazz
> + * @param ids collection of identities
> + * @param fields
> + * @return
> + */
> + protected QueryByCriteria buildPrefetchQuery(Class clazz, Collection ids, FieldDescriptor[] fields)
> + {
> + return QueryFactory.newQuery(clazz, buildPrefetchCriteria(ids, fields));
> }
>
> /**
> * Build the Criteria using IN(...) for single keys
> - * @param ids
> + * @param ids collection of identities
> * @param pkField
> * @return Criteria
> */
> - protected Criteria buildPrefetchCriteriaSingleKey(Collection ids, FieldDescriptor field)
> + private Criteria buildPrefetchCriteriaSingleKey(Collection ids, FieldDescriptor field)
> {
> Criteria crit = new Criteria();
> ArrayList values = new ArrayList();
> @@ -215,7 +231,7 @@
>
> /**
> * Build the Criteria using multiple ORs
> - * @param ids
> + * @param ids collection of identities
> * @param pkFields
> * @return Criteria
> */
>
>
>
> 1.19 +26 -25 db-ojb/src/java/org/apache/ojb/broker/accesslayer/CollectionPrefetcher.java
>
> Index: CollectionPrefetcher.java
> ===================================================================
> RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/CollectionPrefetcher.java,v
> retrieving revision 1.18
> retrieving revision 1.19
> diff -u -r1.18 -r1.19
> --- CollectionPrefetcher.java 28 Nov 2003 14:40:00 -0000 1.18
> +++ CollectionPrefetcher.java 13 Dec 2003 11:59:02 -0000 1.19
> @@ -61,7 +61,6 @@
> import java.util.HashSet;
> import java.util.Iterator;
>
> -
> import org.apache.ojb.broker.Identity;
> import org.apache.ojb.broker.ManageableCollection;
> import org.apache.ojb.broker.OJBRuntimeException;
> @@ -78,27 +77,29 @@
>
> /**
> * Relationship Prefetcher for Collections.
> - *
> - * @author <a href="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a>
> + *
> + * @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
> * @version $Id$
> */
> public class CollectionPrefetcher extends RelationshipPrefetcherImpl
> {
>
> /**
> - * Constructor for CollectionPrefetcher.
> - * @param aBroker
> - * @param anOrd
> - */
> + * Constructor for CollectionPrefetcher.
> + *
> + * @param aBroker
> + * @param anOrd
> + */
> public CollectionPrefetcher(PersistenceBroker aBroker, ObjectReferenceDescriptor anOrd)
> {
> super(aBroker, anOrd);
> }
>
> /**
> - * Build the multiple queries for one relationship because of limitation of IN(...)
> - * @param owners Collection containing all objects of the ONE side
> - */
> + * Build the multiple queries for one relationship because of limitation of IN(...)
> + *
> + * @param owners Collection containing all objects of the ONE side
> + */
> protected Query[] buildPrefetchQueries(Collection owners, Collection children)
> {
> ClassDescriptor cld = getOwnerClassDescriptor();
> @@ -133,10 +134,10 @@
> }
>
> /**
> - * Build the query to perform a batched read get orderBy settings from
> - * CollectionDescriptor
> - * @param ids Collection containing all identities of objects of the ONE side
> - */
> + * Build the query to perform a batched read get orderBy settings from CollectionDescriptor
> + *
> + * @param ids Collection containing all identities of objects of the ONE side
> + */
> protected Query buildPrefetchQuery(Collection ids)
> {
> CollectionDescriptor cds = getCollectionDescriptor();
> @@ -156,18 +157,16 @@
> }
>
> /**
> - * associate the batched Children with their owner object <br>
> - * loop over children
> - */
> + * associate the batched Children with their owner object loop over children
> + */
> protected void associateBatched(Collection owners, Collection children)
> {
> CollectionDescriptor cds = getCollectionDescriptor();
> - ClassDescriptor cld = getItemClassDescriptor();
> + ClassDescriptor cld;
> PersistentField field = cds.getPersistentField();
> PersistenceBroker pb = getBroker();
> - Class ownerTopLevelClass = pb.getTopLevelClass(getOwnerClassDescriptor().getClassOfObject());
> - // this collection type will be used:
> - Class collectionClass = cds.getCollectionClass();
> + Class ownerTopLevelClass = pb.getTopLevelClass(getOwnerClassDescriptor().getClassOfObject());
> + Class collectionClass = cds.getCollectionClass(); // this collection type will be used:
> Object owner, relatedObject;
> Object fkValues[];
> Identity id;
> @@ -175,9 +174,11 @@
> ArrayList list;
> Object result;
>
> - for (Iterator it = children.iterator(); it.hasNext(); )
> + for (Iterator it = children.iterator(); it.hasNext();)
> {
> relatedObject = it.next();
> + // BRJ: use cld of real class
> + cld = getDescriptorRepository().getDescriptorFor(relatedObject.getClass());
> fkValues = cds.getForeignKeyValues(relatedObject, cld);
> id = new Identity(null, ownerTopLevelClass, fkValues);
> list = (ArrayList) ownerIdsToLists.get(id);
> @@ -189,7 +190,7 @@
> list.add(relatedObject);
> }
>
> - for (Iterator it = owners.iterator(); it.hasNext(); )
> + for (Iterator it = owners.iterator(); it.hasNext();)
> {
> owner = it.next();
> id = new Identity(owner, pb);
> @@ -227,7 +228,7 @@
> throw new OJBRuntimeException("Can't create new Collection for owner", e);
> }
> }
> - for (Iterator it2 = list.iterator(); it2.hasNext(); )
> + for (Iterator it2 = list.iterator(); it2.hasNext();)
> {
> col.ojbAdd(it2.next());
> }
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org