Skip to content

Commit

Permalink
MONDRIAN: Fixed bug MONDRIAN-519, ClassCastException: parent/child an…
Browse files Browse the repository at this point in the history
…d no closure

[git-p4: depot-paths = "//open/mondrian/": change = 12574]
  • Loading branch information
Will Gorman committed Apr 7, 2009
1 parent de0ef68 commit 32c8032
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/mondrian/rolap/SqlMemberSource.java
Expand Up @@ -1155,6 +1155,9 @@ public Object getPropertyValue(String propertyName, boolean matchCase) {
List<RolapMember> list = new ArrayList<RolapMember>();
list.add(dataMember);
RolapHierarchy hierarchy = getHierarchy();
if (hierarchy instanceof RolapCubeHierarchy) {
hierarchy = ((RolapCubeHierarchy)hierarchy).getRolapHierarchy();
}
hierarchy.getMemberReader().getMemberChildren(dataMember, list);
return list;
} else {
Expand Down
38 changes: 38 additions & 0 deletions testsrc/main/mondrian/test/ParentChildHierarchyTest.java
Expand Up @@ -1087,6 +1087,44 @@ public void testClosureTableInVirtualCube() {
"Row #0: 152.76\n" +
"Row #0: 60\n"));
}

/**
* This test verifies the fix for MONDRIAN-519, a class cast exception when using
* non-closure parent child hierarchies.
*/
public void testClosureVsNoClosure() {
String cubestart =
"<Cube name=\"HR4C\">\n" +
" <Table name=\"salary\"/>\n" +
" <Dimension name=\"Employees\" foreignKey=\"employee_id\">\n" +
" <Hierarchy hasAll=\"true\" allMemberName=\"All\"\n" +
" primaryKey=\"employee_id\">\n" +
" <Table name=\"employee\"/>\n" +
" <Level name=\"Employee Id\" type=\"Numeric\" uniqueMembers=\"true\"\n" +
" column=\"employee_id\" parentColumn=\"supervisor_id\"\n" +
" nameColumn=\"full_name\" nullParentValue=\"0\">\n";
String closure =
" <Closure parentColumn=\"supervisor_id\" childColumn=\"employee_id\">\n" +
" <Table name=\"employee_closure\"/>\n" +
" </Closure>\n";
String cubeend =
" </Level>\n" +
" </Hierarchy>\n" +
" </Dimension>\n" +
"\n" +
" <Measure name=\"Count\" column=\"employee_id\" aggregator=\"count\" />\n" +
"</Cube>\n";
String mdx =
"select {[Measures].[Count]} ON COLUMNS, NON EMPTY {[Employees].AllMembers} ON ROWS from [HR4C]";
TestContext testClosureContext = TestContext.create(
null,
cubestart + closure + cubeend, null, null, null, null);
String expect = TestContext.toString(testClosureContext.executeQuery(mdx));
TestContext testNoClosureContext = TestContext.create(
null,
cubestart + cubeend, null, null, null, null);
testNoClosureContext.assertQueryReturns(mdx, expect);
}
}

// End ParentChildHierarchyTest.java

0 comments on commit 32c8032

Please sign in to comment.