Reputation: 81
given this query:
final List list =
new JPAQuery(entityManager).from(qdevice).leftJoin(qdevice.parentDevice)
.list(Projections.bean(Device.class, qdevice.id, qdevice.parentDevice));
(parentDevice is type of Device )
The problem is that the query only return the Device when the parentDevice is not null. Why? How to get any value back? If I take out qdevice.parentDevice from the projection than the result is good.
QueryDsl version is 3.2.0
Upvotes: 4
Views: 2762
Reputation: 22200
Could you try this
QDevice device = QDevice.device;
QDevice parentDevice = new QDevice("parentDevice");
List<Device> list = new JPAQuery(entityManager)
.from(device)
.leftJoin(device.parentDevice, parentDevice)
.list(Projections.bean(Device.class, device.id, parentDevice));
The reference to qdevice.parentDevice
in list
might be treated as an inner join, since you don't relate it to the left join.
Upvotes: 3