我对JPA标准有疑问.
这是我的JPA条件查询:
CriteriaBuilder criteriaBuilder = getEm().getCriteriaBuilder();
CriteriaQuery<InventoryItemSumReport> query = criteriaBuilder.createQuery(InventoryItemSumReport.class);
Root<InventoryItemDetail> from = query.from(InventoryItemDetail.class);
Join<InventoryItemDetail, InventoryItem> joinItem = from.join(InventoryItemDetail_.inventoryItem);
Predicate where = criteriaBuilder.lessThanOrEqualTo(from.get(InventoryItemDetail_.effectiveDate), date);
query.multiselect(joinItem.get(InventoryItem_.product),joinItem.get(InventoryItem_.facility),joinItem.get(InventoryItem_.customer));
query.groupBy(joinItem.get(InventoryItem_.product),joinItem.get(InventoryItem_.facility),joinItem.get(InventoryItem_.customer));
query.where(where);
TypedQuery<InventoryItemSumReport> createQuery = getEm().createQuery(query);
List<InventoryItemSumReport> resultList = createQuery.getResultList();
Run Code Online (Sandbox Code Playgroud)
以下是JPA提供程序生成的结果查询:
select
inventoryi1_.PRODUCT_ID as col_0_0_,
inventoryi1_.FACILITY_ID as col_1_0_,
inventoryi1_.CUSTOMER_ID as col_2_0_
from
INVENTORY_ITEM_DETAIL inventoryi0_
inner join
INVENTORY_ITEM inventoryi1_
on inventoryi0_.INVENTORY_ITEM_ID=inventoryi1_.ID
inner join
PRODUCT product2_
on inventoryi1_.PRODUCT_ID=product2_.ID
inner join
FACILITY facility3_
on inventoryi1_.FACILITY_ID=facility3_.ID
inner join
CUSTOMER customer4_
on inventoryi1_.CUSTOMER_ID=customer4_.ID
where
inventoryi0_.EFFECTIVE_DATE<= ?
group by
inventoryi1_.PRODUCT_ID , …Run Code Online (Sandbox Code Playgroud) CDI装饰者可以成为无国籍的ejb吗?
我试过了:
@Decorator
@Stateless
public class WarehouseHandlingDecorator implements SerialKitServiceWarehouseHandling {
@Inject
@Any
@Delegate
protected SerialKitServiceWarehouseHandling serialKitServiceWarehouseHandling;
...
}
Run Code Online (Sandbox Code Playgroud)
我部署在JBoss 6.1上,我收到以下消息:
WELD-000038不能将@Delegate放在一个不在Decorator上的注入点:@New Session bean [类com.eggsweb.production.services.WarehouseHandlingDecorator with qualifiers [@New]; 本地接口是[SerialKitServiceWarehouseHandling]