QueryDSLサブクエリの作成方法


JPA Expressionsを使用したサブクエリの作成
public List<ContainerLocationDTO> getContainerBoxByEmptyItem(String containerBoxId) {
	return from(qContainerLocation)
    		.where(
    			eq(qContainerLocation.locTypeCd, ELocType.RACKCELL.name())
    			, eq(qContainerLocation.containerBoxId, containerBoxId)
    			, qContanerLocation.containerBoxId.isNotNull()
    			, qContainerLocation.containerBoxId.notIn(
    				JPAExpressions
    				.select(qContainerBoxInventory.containerBoxId)
    				.from(qContainerBoxInventory)    		
                    		.where(qContainerBoxInventory.containerBoxId.eq(qContainerLocation.containerBoxId))
			)
		)
            	.leftJoin(qRackCell).on(qRackCell.rackCellId.eq(qContainerLocation.locId))
    		.select(Projections.bean(ContainerLocationDTO.class,
    			qContainerLocation.containerLocId
    			, qContainerLocation.containerBoxId
    			, qContainerLocation.warehouseId
    			, qContainerLocation.locTypeCd
    			, qRackCell.rackCellFloor
    			, qRackCell.rackCellRow
    			, qRackCell.rackCellColumn
    			, qRackCell.rackCellName
    		))
    		.orderBy(qContainerLocation.containerBoxId.asc())
    		.fetch();
}