db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Mahler <thm...@web.de>
Subject Re: cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer BasePrefetcher.java CollectionPrefetcher.java
Date Sat, 13 Dec 2003 12:21:50 GMT
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


Mime
View raw message