use of com.blazebit.persistence.parser.EntityMetamodel in project blaze-persistence by Blazebit.
the class FullEntityLoader method createQueryString.
private String createQueryString(EntityViewManagerImpl evm, ManagedViewType<?> subviewType, boolean multiple) {
EntityMetamodel entityMetamodel = evm.getMetamodel().getEntityMetamodel();
EntityType<?> entityType = entityMetamodel.getEntity(entityClass);
// We can't query embeddables
if (entityType == null) {
return null;
}
Set<String> fetchJoinableRelations = new HashSet<>(subviewType.getAttributes().size());
addFetchJoinableRelations(fetchJoinableRelations, "", subviewType);
CriteriaBuilderFactory cbf = evm.getCriteriaBuilderFactory();
if (fetchJoinableRelations.isEmpty()) {
return null;
} else {
CriteriaBuilder<?> criteriaBuilder = cbf.create(null, entityClass).fetch(fetchJoinableRelations.toArray(new String[fetchJoinableRelations.size()]));
if (multiple) {
criteriaBuilder.where(JpaMetamodelUtils.getSingleIdAttribute(entityType).getName()).inExpressions(":entityIds");
} else {
criteriaBuilder.where(JpaMetamodelUtils.getSingleIdAttribute(entityType).getName()).eqExpression(":id");
}
return criteriaBuilder.getQueryString();
}
}
Aggregations