Bug 104102

Summary: Improper handling of associations in DataQuery.addPath()
Product: [Retired] Red Hat Web Application Framework Reporter: Mike Bonnet <mikeb>
Component: persistenceAssignee: Archit Shah <archit.shah>
Status: CLOSED WONTFIX QA Contact: Jon Orris <jorris>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.0   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-11-10 21:02:52 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 108447    
Attachments:
Description Flags
A testcase that reproduces the bug. none

Description Mike Bonnet 2003-09-09 21:06:57 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 Galeon/1.2.7 (X11; Linux i686; U;) Gecko/20030131

Description of problem:
DataQuery.addPath() will allow you to add a path to a [0..n] association, and to
filter on that path.  This is a very useful feature, and fills long-standing gap
in Persistence functionality (the ability to add joins to a query in real time).

However, if you then try to retrieve the [0..n] association that you filtered
on, you'll get a ClassCastException.  While you should be retrieving a
DataAssociation, persistence is returning a DataObject, and this causes the CCE.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
See first attachment for a reproducable test case

Additional info:

Comment 1 Mike Bonnet 2003-09-09 21:14:26 UTC
Created attachment 94340 [details]
A testcase that reproduces the bug.

This is a simple application that reproduces the bug.  To use it, you must have
the CCM development environment installed.

1. Create a new project called testing: $ ccm-devel-create.pl testing
2. $ ccm-profile testing
3. Delete all the generated files: $ cd .. && rm -rf testing
4. Untar the attachment into the current directory: $ tar xzvf
add-path-test.tar.gz
5. Edit config.vars for you environment.
6. Load the data model for Core and the testing project.
7. ant runtests

The tests should complete successfully.  Instead, you'll see a
ClassCastException like this:

java.lang.ClassCastException: com.arsdigita.persistence.DataObjectImpl
	at
com.arsdigita.persistence.DataAssociationCursorImpl.<init>(DataAssociationCursorImpl.java:38)

	at
com.arsdigita.persistence.DataAssociationImpl.<init>(DataAssociationImpl.java:39)

	at
com.arsdigita.persistence.DataObjectImpl.get(DataObjectImpl.java:167)
	at com.arsdigita.domain.DomainObject.get(DomainObject.java:436)
	at test.Foo.getBarAssociations(Foo.java:28)
	at test.FooTest.testAddPath(FooTest.java:39)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

	at
com.arsdigita.tools.junit.framework.BaseTestCase.runBare(BaseTestCase.java:47)
	at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
	at
com.arsdigita.tools.junit.extensions.BaseTestSetup$1.protect(BaseTestSetup.java:60)

	at
com.arsdigita.tools.junit.extensions.BaseTestSetup.run(BaseTestSetup.java:64)

Comment 2 Rafael H. Schloming 2003-11-27 02:51:16 UTC
I think this is actually fixed on the trunk now since it is just
another manifestation of bug 104889. We should probably add the test
case you've supplied to the persistence test suite before closing this
though.