"select new" + "join fetch" = "owner of the fetched association was not present in the select list"

Description

I want to create a List<B>, each B containing an entity with "A" type, and I also want for each A to force fetching of its "C" property.

public class B {
private A a;
public B(A a) {
this.a = a;
}
}

@Entity
public class A {
@ManyToOne @JoinColumn
private C c;
// +get/setter ...
}

@Entity
public class C {
@Column
private String d;
// +get/setter ...
// +@OneToMany
}

Here is the HQL :
select new B(a) from A a left join fetch a.c

I have that message :
org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list

When invoking only "from A a left join fetch a.c", all is good and I have ma List<A> with its "C" properties fetched.

I think there is a little bug here ... or did I forget something ?

Environment

None

Status

Assignee

Unassigned

Reporter

Anthony Ogier

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major
Configure