I have the following classes:
Person.java
class Person {
String name;
Set<Hotel> visitedHotels;
String someOtherData;
public Person() {}
public Person(String name, Set<Hotel> visitedHotels) {
this.name;
this.visitedHotels = this.visitedHotels;
}
// getters & setters
}
Hotel.java
class Hotel {
// some code
}
For security reasons "someOtherData" should sometimes not be loaded.
So I tried the following HQL:
select new Person( p.name , elements(p.visitedHotels) ) from Person p
or
select new Person( p.name , hotels ) from Person p left join p.visitedHotels hotels
But it doesn’t work - error: Unable to locate appropriate constructor on class Person.
Is there a possibility to select the collection of hotels together with the person name?