1

I have a HQL query like this:

 string  QueryString =   select client, transporter 
    from BaseClient as client, BaseTrans as transporter
    where client.tr = transporter.Id and transporter.badge = 1
    order by transporter.date;

But when I use this hql I receive the following error :

The value "System.Object[]" is not of type "xxx" and cannot be used in this generic collection. Parameter name: value

Just like Example but, when I omit the Transporter entity in my select it works.

Like :

string  QueryString =  select client
 from BaseClient as client, BaseTrans as transporter 
 where client.tr = transporter.Id and transporter.badge = 1
 order by transporter.date;

But I need transporter in my select, because I use order by.

By the way, I have 2 hbm Client.hbm.xml and Transporter.hbm.xml. Each hbm have their own Class and Table.

i call it with :

IQuery requete = this.CreateQuery(QueryString);

   IList<Client> executions = requete.List<Client>();

it hang on this line, when hibernate try to convert to the list

2
  • How does your code look like where you call this HQL ? Commented Oct 2, 2017 at 12:02
  • thanks you for responding, i modifie my question. i add the line how i call it Commented Oct 2, 2017 at 12:24

1 Answer 1

1

This happens because your result-set will likely be a multi-dimensional array where the first column represents a Client and the 2nd column contains a Transporter.

What happens if you change your code like this:

IQuery requete = this.CreateQuery(QueryString);

var result = requete.List();

var clients = result[0] as IEnumerable<Client>;

(I have no NHibernate installed on this system so I cannot just test something out quickly without creating and setting up a new project. :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.