/**
* prefetch ProductGroups for Articles
*/
public void testPrefetchedReferencesSingleKey()
{
ClassDescriptor cldProductGroup = broker.getClassDescriptor(ProductGroup.class);
ClassDescriptor cldArticle = broker.getClassDescriptor(Article.class);
Class productGroupProxy = cldProductGroup.getProxyClass();
Class articleProxy = cldArticle.getProxyClass();
//
// use ProductGroup and Articles with disabled Proxy
//
broker.clearCache();
cldProductGroup.setProxyClass(null);
cldProductGroup.setProxyClassName(null);
cldArticle.setProxyClass(null);
cldArticle.setProxyClassName(null);
broker.getDescriptorRepository().setClassDescriptor(cldProductGroup);
broker.getDescriptorRepository().setClassDescriptor(cldArticle);
Criteria crit = new Criteria();
crit.addNotNull("productGroupId");
crit.addLessOrEqualThan("productGroupId", new Integer(5));
QueryByCriteria q = QueryFactory.newQuery(Article.class, crit);
q.addOrderByDescending("productGroupId");
q.addPrefetchedRelationship("productGroup");
Collection results = broker.getCollectionByQuery(q);
Set pgs = new HashSet();
Iterator iter = results.iterator();
while(iter.hasNext())
{
InterfaceArticle a = (InterfaceArticle) iter.next();
pgs.add(a.getProductGroup().getName());
}
assertTrue(pgs.size() > 0);
String pgsString = pgs.toString();
//
// use ProductGroup and Articles with original Proxy settings
//
broker.clearCache();
cldProductGroup.setProxyClass(productGroupProxy);
cldProductGroup.setProxyClassName(productGroupProxy.getName());
cldArticle.setProxyClass(articleProxy);
cldArticle.setProxyClassName(articleProxy.getName());
broker.getDescriptorRepository().setClassDescriptor(cldProductGroup);
broker.getDescriptorRepository().setClassDescriptor(cldArticle);
crit = new Criteria();
crit.addNotNull("productGroupId");