IStatement statement;
statement = null;
if(dataSource instanceof IHibernateDataSource) {
statement = new HQLStatement((IHibernateDataSource)dataSource, query);
} else if (dataSource instanceof JPADataSource) {
statement = new JPQLStatement((JPADataSource)dataSource, query);
} else {
throw new RuntimeException("Impossible to create statement from a datasource of type [" + dataSource.getClass().getName() + "]");
}