Blaze-Persistence Querydsl 集成是否支持投影?
Is Blaze-Persistence Querydsl integration support projections?
如何将投影与 Blaze-Persistence Querydsl 一起使用?
在下面的示例中,当 criteria.getEmail() 给我 NullPointerException。
那么我如何克服 NullPointerException 以获得更多信息?
cbf.create(em, WalletReportDto.class)
.fromSubquery(WalletCTE.class, "offerCTO").from(TenantBalanceOffers.class, "tbo")
.bind("walletId").select("tbo.wallet.id")
.bind("amount").select("SUM(tbo.amount)")
.groupBy("tbo.wallet.id").end()
.joinOn(TenantWallet.class, "tw", JoinType.INNER)
.onExpression("offerCTO.walletId = tw.id")
.end() //
.select("MIN(tw.createdDate)", "fromtDate").select("MAX(tw.createdDate)", "toDate")
.select("tw.customer.email", "email")
.select("sum(offerCTO.amount)").where("tw.customer.email").eq(criteria.getEmail())
.groupBy("tw.id")
.getResultList();
您需要使用 Blaze-Persistence Querydsl 集成才能将 Querydsl 投影与 Blaze-Persistence 的查询功能结合使用。
List<WalletReportDto> result = new BlazeJPAQuery<>(em, cbf)
.from(new BlazeJPAQuery<>()
.from(QTenantBlanceOffers.tenantBlanceOffers)
.bind(QWalletCTE.walletCTE.walletId, QTenantBlanceOffers.tenantBlanceOffers.wallet.id)
.bind(QWalletCTE.walletCTE.amount, QTenantBlanceOffers.tenantBlanceOffers.amount.sum())
, QWalletCTE.walletCTE)
.innerJoin(QTenantWallet.tenantWallet)
.on(QTenantWallet.tenantWallet.id.eq(QWalletCTE.walletCTE.walletId))
.transform(Projections.bean(
WalletReportDto.class,
QTenantWallet.tenantWallet.createdDate.min(),
QTenantWallet.tenantWallet.createdDate.max(),
QTenantWallet.tenantWallet.customer.email,
QWalletCTE.walletCTE.id
)
如何将投影与 Blaze-Persistence Querydsl 一起使用?
在下面的示例中,当 criteria.getEmail() 给我 NullPointerException。 那么我如何克服 NullPointerException 以获得更多信息?
cbf.create(em, WalletReportDto.class)
.fromSubquery(WalletCTE.class, "offerCTO").from(TenantBalanceOffers.class, "tbo")
.bind("walletId").select("tbo.wallet.id")
.bind("amount").select("SUM(tbo.amount)")
.groupBy("tbo.wallet.id").end()
.joinOn(TenantWallet.class, "tw", JoinType.INNER)
.onExpression("offerCTO.walletId = tw.id")
.end() //
.select("MIN(tw.createdDate)", "fromtDate").select("MAX(tw.createdDate)", "toDate")
.select("tw.customer.email", "email")
.select("sum(offerCTO.amount)").where("tw.customer.email").eq(criteria.getEmail())
.groupBy("tw.id")
.getResultList();
您需要使用 Blaze-Persistence Querydsl 集成才能将 Querydsl 投影与 Blaze-Persistence 的查询功能结合使用。
List<WalletReportDto> result = new BlazeJPAQuery<>(em, cbf)
.from(new BlazeJPAQuery<>()
.from(QTenantBlanceOffers.tenantBlanceOffers)
.bind(QWalletCTE.walletCTE.walletId, QTenantBlanceOffers.tenantBlanceOffers.wallet.id)
.bind(QWalletCTE.walletCTE.amount, QTenantBlanceOffers.tenantBlanceOffers.amount.sum())
, QWalletCTE.walletCTE)
.innerJoin(QTenantWallet.tenantWallet)
.on(QTenantWallet.tenantWallet.id.eq(QWalletCTE.walletCTE.walletId))
.transform(Projections.bean(
WalletReportDto.class,
QTenantWallet.tenantWallet.createdDate.min(),
QTenantWallet.tenantWallet.createdDate.max(),
QTenantWallet.tenantWallet.customer.email,
QWalletCTE.walletCTE.id
)