My HQL is (unexpectedly) returning a list of objects[] rather than the entity I have specified in the HQL (and the generic List method).
It seems to be trying to do a Report Query (which would happen if I specified select items). But I simply want a list of Accounts - see code below.
After running the query below, I can't call List<Account> because it throws this error:
System.ArgumentException: The value "System.Object[]" is not of type "Account" and cannot be used in this generic collection.
But if I change it to
Code:
IList bla = query.List();
then I can see that it has returned 5 distinct objects, each one corresponding to the joins I have made. If this is some feature I didn't know about... all good and well, otherwise can anyone explain why it's giving me lists of objects[] instead type 'Account'?
Code:
IQuery query =
Session.CreateQuery(
"from Account account join account.Type as type "
+ "join type.Product as product "
+ "join account.AccountCustodianAccounts as aca "
+ "join aca.CustodianAccount "
+ "where product.Name = :ProductName");
query.SetString("ProductName", "Nice Product");
IList bla = query.List();
// this will throw an exception -> IList<Account> accounts = query.List<Account>();