本文整理了Java中javax.persistence.criteria.Root.getJavaType
方法的一些代码示例,展示了Root.getJavaType
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Root.getJavaType
方法的具体详情如下:
包路径:javax.persistence.criteria.Root
类名称:Root
方法名:getJavaType
暂无
代码示例来源:origin: kiegroup/jbpm
/**
* This is a helper method to retrieve a particular {@link Root} from a {@link CriteriaQuery} instance
*
* @param query The {@link CriteriaQuery} instance that we're building
* @param queryType The {@link Class} matching the {@link Root} we want
* @return The {@link Root} matching the given {@link Class} or null if it's not in the query
*/
public static <T> Root getRoot(AbstractQuery<T> query, Class queryType) {
Root<?> table = null;
for( Root<?> root : query.getRoots() ) {
if( root.getJavaType().equals(queryType) ) {
table = root;
break;
}
}
return table;
}
代码示例来源:origin: kiegroup/jbpm
} else {
throw new IllegalStateException("List id [" + getQueryParameterIdNameMap().get(Integer.parseInt(criteria.getListId()))
+ "] is not supported for queries on " + table.getJavaType().getSimpleName() + ".");
代码示例来源:origin: kiegroup/jbpm
@Override
protected <T> Expression getEntityField(CriteriaQuery<T> query, String listId, Attribute attr) {
if( attr == null ) {
return null;
}
Root<TaskImpl> taskRoot = null;
Join<TaskImpl, TaskDataImpl> taskDataJoin = null;
Join<TaskImpl, PeopleAssignmentsImpl> peopAssignJoin = null;
for( Root root : query.getRoots() ) {
if( TaskImpl.class.equals(root.getJavaType()) ) {
taskRoot = (Root<TaskImpl>) root;
for( Join<TaskImpl, ?> join : taskRoot.getJoins() ) {
if( TaskDataImpl.class.equals(join.getJavaType()) ) {
taskDataJoin = (Join<TaskImpl, TaskDataImpl>) join;
} else if( PeopleAssignmentsImpl.class.equals(join.getJavaType()) ) {
peopAssignJoin = (Join<TaskImpl, PeopleAssignmentsImpl>) join;
}
}
}
}
assert taskRoot != null : "Unable to find TaskImpl Root in query!";
if( taskDataJoin == null ) {
taskDataJoin = taskRoot.join(TaskImpl_.taskData);
}
assert taskDataJoin != null : "Unable to find TaskDataImpl Join in query!";
return taskImplSpecificGetEntityField(query, taskRoot,
taskDataJoin, peopAssignJoin,
listId, attr);
}
代码示例来源:origin: kiegroup/jbpm
private <T> void useDistinctWhenLefOuterJoinsPresent(CriteriaQuery<T> criteriaQuery) {
boolean useDistinct = false;
Root<TaskImpl> taskRoot = null;
ROOTS_FOR: for( Root root : criteriaQuery.getRoots() ) {
if( TaskImpl.class.equals(root.getJavaType()) ) {
taskRoot = (Root<TaskImpl>) root;
for( Join<TaskImpl, ?> taskJoin : taskRoot.getJoins() ) {
if( PeopleAssignmentsImpl.class.equals(taskJoin.getJavaType()) ) {
Join<TaskImpl, PeopleAssignmentsImpl> peopleAssignJoin = (Join<TaskImpl, PeopleAssignmentsImpl>) taskJoin;
if( JoinType.LEFT.equals(peopleAssignJoin.getJoinType()) ) {
useDistinct = true;
break ROOTS_FOR;
}
for( Join peopleAssignJoinJoin : peopleAssignJoin.getJoins() ) {
if( JoinType.LEFT.equals(peopleAssignJoinJoin.getJoinType()) ) {
useDistinct = true;
break ROOTS_FOR;
}
}
}
}
}
}
if( useDistinct ) {
criteriaQuery.distinct(true);
}
}
代码示例来源:origin: Impetus/Kundera
Class entityClazz = from.getJavaType();
代码示例来源:origin: org.omnifaces/omnipersistence
@Override
public Class<? extends X> getJavaType() {
return getWrapped().getJavaType();
}
代码示例来源:origin: com.charlyghislain.authenticator/authenticator-ejb
private static <T extends WithId> Root<T> getMainSelection(CriteriaQuery<T> query) {
return query.getRoots().stream()
.filter(r -> r.getJavaType().isAssignableFrom(query.getResultType()))
.map(r -> (Root<T>) r)
.filter(r -> !r.isCorrelated())
.findFirst()
.orElseThrow(IllegalStateException::new);
}
代码示例来源:origin: ZhongjunTian/spring-repository-plus
private void join(Root<Object> root, List<String> joinFetchTables, JoinType type) {
if (joinFetchTables != null && (joinFetchTables.size() > 0)) {
logger.debug("{} join root {} with table {}",
type.name(), root.getJavaType(), joinFetchTables);
for (String table : joinFetchTables) {
if (table != null)
root.fetch(table, type);
}
}
}
代码示例来源:origin: org.ligoj.bootstrap/bootstrap-business
/**
* Return the ORM path from the given rule.
*/
private <T> Path<T> getOrmPath(final Root<U> root, final BasicRule rule) {
final String path = mapping.getOrDefault(rule.getField(), mapping.containsKey("*") ? rule.getField() : null);
if (path == null) {
// Invalid path, coding issue or SQL injection attempt
log.error(String.format("Non mapped property '%s' found for entity class '%s'", rule.getField(), root.getJavaType().getName()));
return null;
}
return getOrmPath(root, path);
}
代码示例来源:origin: org.jboss.pressgang.ccms/pressgang-ccms-query
/**
* Find the Root with type class on CriteriaQuery Root Set
*
* @param <T> root type
* @param query criteria query
* @param clazz root type
* @return Root<T> of null if none
*/
public static <T> Root<T> findRoot(CriteriaQuery<?> query, Class<T> clazz) {
for (Root<?> r : query.getRoots()) {
if (clazz.equals(r.getJavaType())) {
return (Root<T>) r.as(clazz);
}
}
return null;
}
代码示例来源:origin: jaxio/jpa-query-by-example
private <T> Predicate onSimplePrimaryKey(Root<T> root, CriteriaBuilder builder, SearchParameters sp, List<SingularAttribute<?, ?>> properties) {
List<Serializable> ids = hibernateSearchUtil.findId(root.getJavaType(), sp, properties);
if (ids == null) {
return null;
} else if (ids.isEmpty()) {
return builder.disjunction();
}
return jpaUtil.concatPredicate(sp, builder, root.get("id").in(ids));
}
代码示例来源:origin: jaxio/generated-projects
private <T> Predicate onSimplePrimaryKey(Root<T> root, CriteriaBuilder builder, SearchParameters sp, List<SingularAttribute<?, ?>> properties) {
List<Serializable> ids = hibernateSearchUtil.findId(root.getJavaType(), sp, properties);
if (ids == null) {
return null;
} else if (ids.isEmpty()) {
return builder.disjunction();
}
return jpaUtil.concatPredicate(sp, builder, root.get("id").in(ids));
}
代码示例来源:origin: jaxio/generated-projects
private <T extends Identifiable<?>> Predicate onCompositePrimaryKeys(Root<T> root, CriteriaBuilder builder, SearchParameters sp,
List<SingularAttribute<?, ?>> properties) {
List<? extends T> found = hibernateSearchUtil.find(root.getJavaType(), sp, properties);
if (found == null) {
return null;
} else if (found.isEmpty()) {
return builder.disjunction();
}
List<Predicate> predicates = newArrayList();
for (T t : found) {
predicates.add(byExampleOnEntity(root, t, sp, builder));
}
return jpaUtil.concatPredicate(sp, builder, jpaUtil.orPredicate(builder, predicates));
}
代码示例来源:origin: jaxio/jpa-query-by-example
private <T extends Identifiable<?>> Predicate onCompositePrimaryKeys(Root<T> root, CriteriaBuilder builder, SearchParameters sp,
List<SingularAttribute<?, ?>> properties) {
List<? extends T> found = hibernateSearchUtil.find(root.getJavaType(), sp, properties);
if (found == null) {
return null;
} else if (found.isEmpty()) {
return builder.disjunction();
}
List<Predicate> predicates = newArrayList();
for (T t : found) {
predicates.add(byExampleOnEntity(root, t, sp, builder));
}
return jpaUtil.concatPredicate(sp, builder, jpaUtil.orPredicate(builder, predicates));
}
代码示例来源:origin: org.apache.openjpa/openjpa-persistence
public void populate(Object parsed, ExpressionStoreQuery query) {
CriteriaQueryImpl<?> c = (CriteriaQueryImpl<?>) parsed;
query.invalidateCompilation();
query.getContext().setCandidateType(c.getRoot().getJavaType(), true);
query.setQuery(parsed);
}
代码示例来源:origin: org.apache.openejb.patch/openjpa-persistence
public void populate(Object parsed, ExpressionStoreQuery query) {
CriteriaQueryImpl<?> c = (CriteriaQueryImpl<?>) parsed;
query.invalidateCompilation();
query.getContext().setCandidateType(c.getRoot().getJavaType(), true);
query.setQuery(parsed);
}
代码示例来源:origin: org.apache.openejb.patch/openjpa
public void populate(Object parsed, ExpressionStoreQuery query) {
CriteriaQueryImpl<?> c = (CriteriaQueryImpl<?>) parsed;
query.invalidateCompilation();
query.getContext().setCandidateType(c.getRoot().getJavaType(), true);
query.setQuery(parsed);
}
代码示例来源:origin: org.apache.openjpa/openjpa-all
public void populate(Object parsed, ExpressionStoreQuery query) {
CriteriaQueryImpl<?> c = (CriteriaQueryImpl<?>) parsed;
query.invalidateCompilation();
query.getContext().setCandidateType(c.getRoot().getJavaType(), true);
query.setQuery(parsed);
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
/**
* Correlates a root of the enclosing query to a root of the subquery and
* returns the subquery root.
*
* @param parentRoot
* a root of the containing query
* @return subquery root
*/
public <Y> Root<Y> correlate(Root<Y> parentRoot){
RootImpl root = new RootImpl(parentRoot.getModel(), metamodel, parentRoot.getJavaType(), internalCorrelate((FromImpl)parentRoot), parentRoot.getModel(), (FromImpl) parentRoot);
integrateRoot(root);
return root;
}
代码示例来源:origin: org.jboss.pressgang.ccms/pressgang-ccms-query
/**
* Copy Criteria without Selection
*
* @param from source Criteria
* @param to destination Criteria
*/
public static void copyCriteriaNoSelection(CriteriaQuery<?> from, CriteriaQuery<?> to) {
// Copy Roots
for (Root<?> root : from.getRoots()) {
Root<?> dest = to.from(root.getJavaType());
dest.alias(getOrCreateAlias(root));
copyJoins(root, dest);
}
if (from.getGroupList() != null) to.groupBy(from.getGroupList());
to.distinct(from.isDistinct());
if (from.getGroupRestriction() != null) to.having(from.getGroupRestriction());
if (from.getRestriction() != null) to.where(from.getRestriction());
if (from.getOrderList() != null) to.orderBy(from.getOrderList());
}
内容来源于网络,如有侵权,请联系作者删除!