I run a query directly on the database and it completes within few seconds but from Java it takes 22 seconds. Looks like it downloads the whole Cube definition metadata before actually executing the query.
I am using olap4j classes as follows....
public static String query = "Some query"
OlapConnection olapConnection = ((OlapConnection) DriverManager.getConnection("some url")).unwrap(OlapConnection.class);
OlapStatement olapStatement = olapConnection.createStatement();
CellSet cellSet = olapStatement.executeOlapQuery(query);