I have a SQL like this
select * from sys_region as sr
left join
(select count(*) as c,parent_code from sys_region * group by parent_code )
as c on c.parent_code = sr.parent_code
Also, there is entity
@Getter
@Setter
@CTE
public class SysRegion extends BaseIdEntity {
@Column(length = 128)
private String name;
@Column
private Short level;
@Column
@ColumnDefault("0")
private BigInteger parentCode;
@Column
@ColumnDefault("0")
private BigInteger areaCode;
@Column
private String cityCode;
@Column
private Integer zipCode;
@Column
@ColumnDefault("0.0")
private BigDecimal lng;
@Column
@ColumnDefault("0.0")
private BigDecimal lat;
@Column
private String shortName;
@Column
private String mergerName;
}
And I am using quarkus with queryDSL and Blaze persistence
How to implement SQL query using that mapping to my entity?
And I saw this link
Do not have full example for this case left join with sub query and mapping to entity?