jpa - Hibernate JPQL Constructor Expression doesn't work with OneToMany field -


when try use constructor expression in jpql query

class companyprojection {     string name;     list<employee> employees;      public companyprojection (string name, list<employee> employees) {         ...     }     }  class company {     string name;      @onetomany(mappedby = "company")     list<employee> employees; }  class employee {      @manytoone      company company; } 

select com.foo.companyprojection(c.name, c.employees) company c

i org.hibernate.hql.internal.ast.querysyntaxexception: unable locate appropriate constructor on class [com.foo.companyprojection]. expected arguments are: java.lang.string, com.foo.employee[........]

from stacktrace above, understand hibernate expects second constructor argument have employee.class type instead of list.class.

but c.employees list. don't understand if bug in hibernate, or if i'm misusing it?

user error.

using multi-valued fields in select clause of jpql illegal syntax. see jpql bnf.


Comments

Popular posts from this blog

python - Error: Unresolved reference 'selenium' What is the reason? -

ios - Pass NSDictionary from Javascript to Objective-c in JavascriptCore -

php - Need to store a large amount of data in session with CI 3 but on storing large data in session it is itself destorying automatically -