本文整理了Java中javax.persistence.criteria.Join.getAttribute()
方法的一些代码示例,展示了Join.getAttribute()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Join.getAttribute()
方法的具体详情如下:
包路径:javax.persistence.criteria.Join
类名称:Join
方法名:getAttribute
[英]Return the metamodel attribute corresponding to the join.
[中]返回与联接对应的元模型属性。
代码示例来源:origin: spring-projects/spring-data-jpa
/**
* Returns an existing join for the given attribute if one already exists or creates a new one if not.
*
* @param from the {@link From} to get the current joins from.
* @param attribute the {@link Attribute} to look for in the current joins.
* @return will never be {@literal null}.
*/
private static Join<?, ?> getOrCreateJoin(From<?, ?> from, String attribute) {
for (Join<?, ?> join : from.getJoins()) {
boolean sameName = join.getAttribute().getName().equals(attribute);
if (sameName && join.getJoinType().equals(JoinType.LEFT)) {
return join;
}
}
return from.join(attribute, JoinType.LEFT);
}
代码示例来源:origin: kiegroup/jbpm
private static ListJoin<PeopleAssignmentsImpl,OrganizationalEntityImpl> [] getPeopleAssignmentsJoins(
Join<TaskImpl,PeopleAssignmentsImpl> peopleAssignJoin) {
ListJoin<PeopleAssignmentsImpl,OrganizationalEntityImpl> [] joins = new ListJoin[3];
for( Join<PeopleAssignmentsImpl,?> join : peopleAssignJoin.getJoins() ) {
String joinFieldName = join.getAttribute().getName();
if( PeopleAssignmentsImpl_.businessAdministrators.getName().equals(joinFieldName) ) {
joins[0] = (ListJoin<PeopleAssignmentsImpl,OrganizationalEntityImpl>) join;
} else if( PeopleAssignmentsImpl_.potentialOwners.getName().equals(joinFieldName) ) {
joins[1] = (ListJoin<PeopleAssignmentsImpl,OrganizationalEntityImpl>) join;
} else if( PeopleAssignmentsImpl_.taskStakeholders.getName().equals(joinFieldName) ) {
joins[2] = (ListJoin<PeopleAssignmentsImpl,OrganizationalEntityImpl>) join;
}
}
if( joins[0] == null ) {
joins[0] = peopleAssignJoin.join(PeopleAssignmentsImpl_.businessAdministrators, JoinType.LEFT);
}
if( joins[1] == null ) {
joins[1] = peopleAssignJoin.join(PeopleAssignmentsImpl_.potentialOwners, JoinType.LEFT);
}
if( joins[2] == null ) {
joins[2] = peopleAssignJoin.join(PeopleAssignmentsImpl_.taskStakeholders, JoinType.LEFT);
}
assert joins[0] != null : "Could not find business administrators join!";
assert joins[1] != null : "Could not find potential owners join!";
assert joins[2] != null : "Could not find task stakeholders join!";
return joins;
}
代码示例来源:origin: kiegroup/jbpm
for( Join<F, ?> join : grandparentJoin.getJoins() ) {
if( join.getJavaType().equals(toAttrJoinType) ) {
if( join.getAttribute().equals(parentJoinAttr) ) {
fieldParentJoin = (Join<F, T>) join;
if( ! JoinType.INNER.equals(fieldParentJoin.getJoinType()) ) {
代码示例来源:origin: org.omnifaces/omnipersistence
@Override
public Attribute<? super X, ?> getAttribute() {
return join.getAttribute();
}
代码示例来源:origin: ActiveJpa/activejpa
private <T> Join<T, ?> getJoin(String name, Set<Join<T, ?>> joins) {
for (Join<T, ?> join : joins) {
if (join.getAttribute().getName().equals(name)) {
return join;
}
}
return null;
}
}
代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs
private Path<?> getExistingJoinProperty(From<?, ?> element, String prop) {
final Set<?> joins = element.getJoins();
for (Object object : joins) {
Join<?, ?> join = (Join<?, ?>) object;
if (join.getAttribute().getName().equals(prop)) {
return join;
}
}
return null;
}
代码示例来源:origin: apache/cxf
private Path<?> getExistingJoinProperty(From<?, ?> element, String prop) {
final Set<?> joins = element.getJoins();
for (Object object : joins) {
Join<?, ?> join = (Join<?, ?>) object;
if (join.getAttribute().getName().equals(prop)) {
return join;
}
}
return null;
}
代码示例来源:origin: org.apache.cxf/cxf-rt-rs-extension-search
private Path<?> getExistingJoinProperty(From<?, ?> element, String prop) {
final Set<?> joins = element.getJoins();
for (Object object : joins) {
Join<?, ?> join = (Join<?, ?>) object;
if (join.getAttribute().getName().equals(prop)) {
return join;
}
}
return null;
}
代码示例来源:origin: org.ligoj.bootstrap/bootstrap-business
/**
* Retrieve an existing join within the ones within the given root and that match to given attribute.
*
* @param from
* the from source element.
* @param attribute
* the attribute to join
* @return The join/fetch path if it exists.
* @param <U>
* The source type of the {@link Join}
* @param <T>
* The resolved entity type of the path value.
*/
@SuppressWarnings("unchecked")
protected <U, T> PathImplementor<T> getJoinPath(final From<?, U> from, final Attribute<?, ?> attribute) {
// Search within current joins
for (final Join<U, ?> join : from.getJoins()) {
if (join.getAttribute().equals(attribute)) {
return fixAlias((Join<U, T>) join, aliasCounter);
}
}
return null;
}
代码示例来源:origin: babyfish-ct/babyfish
private static boolean isLeftOrNonNullReferenceJoin(Join<?, ?> join, boolean dbSchemaStrict) {
if (join.getAttribute().isCollection()) {
return false;
}
if (join.getJoinType() == JoinType.LEFT) {
return true;
}
if (!dbSchemaStrict) {
return false;
}
SingularAttribute<?, ?> singularAttribute = (SingularAttribute<?, ?>)join.getAttribute();
return
!singularAttribute.isOptional() &&
singularAttribute.getPersistentAttributeType() == PersistentAttributeType.MANY_TO_ONE;
}
}
代码示例来源:origin: org.seedstack.addons.jpa/jpa
/**
* Find an existing join for the property or create a new join.
*
* @param property property to be joined
* @param from clause letting us keep track of all already existing joins
* @return the join
*/
private static Join<?, ?> findOrCreateJoin(String property, From<?, ?> from) {
for (Join<?, ?> rootJoin : from.getJoins()) {
if (rootJoin.getAttribute().getName().equals(property)) {
return rootJoin;
}
}
return from.join(property);
}
}
代码示例来源:origin: com.introproventures/graphql-jpa-query-schema
private Join<?,?> reuseJoin(From<?, ?> path, String fieldName, boolean outer) {
for (Join<?,?> join : path.getJoins()) {
if (join.getAttribute().getName().equals(fieldName)) {
if ((join.getJoinType() == JoinType.LEFT) == outer) {
logger.debug("Reusing existing join for field " + fieldName);
return join;
}
}
}
return outer ? path.join(fieldName, JoinType.LEFT) : path.join(fieldName);
}
代码示例来源:origin: org.apache.openjpa/openjpa-persistence
protected void evalAccessPaths(QueryExpressions exps, ExpressionFactory factory, CriteriaQueryImpl<?> q) {
Set<ClassMetaData> metas = new HashSet<ClassMetaData>();
MetamodelImpl metamodel = q.getMetamodel();
for (Root<?> root : q.getRoots()) {
metas.add(((AbstractManagedType<?>)root.getModel()).meta);
for (Join<?,?> join : root.getJoins()) {
Class<?> cls = join.getAttribute().getJavaType();
if (join.getAttribute().isAssociation()) {
ClassMetaData meta = metamodel.getRepository().getMetaData(cls, null, true);
PersistenceType type = MetamodelImpl.getPersistenceType(meta);
if (type == PersistenceType.ENTITY || type == PersistenceType.EMBEDDABLE)
metas.add(meta);
}
}
}
// TODO -- need to handle subqueries
exps.accessPath = metas.toArray(new ClassMetaData[metas.size()]);
}
代码示例来源:origin: org.apache.openjpa/openjpa-all
protected void evalAccessPaths(QueryExpressions exps, ExpressionFactory factory, CriteriaQueryImpl<?> q) {
Set<ClassMetaData> metas = new HashSet<ClassMetaData>();
MetamodelImpl metamodel = q.getMetamodel();
for (Root<?> root : q.getRoots()) {
metas.add(((AbstractManagedType<?>)root.getModel()).meta);
for (Join<?,?> join : root.getJoins()) {
Class<?> cls = join.getAttribute().getJavaType();
if (join.getAttribute().isAssociation()) {
ClassMetaData meta = metamodel.getRepository().getMetaData(cls, null, true);
PersistenceType type = MetamodelImpl.getPersistenceType(meta);
if (type == PersistenceType.ENTITY || type == PersistenceType.EMBEDDABLE)
metas.add(meta);
}
}
}
// TODO -- need to handle subqueries
exps.accessPath = metas.toArray(new ClassMetaData[metas.size()]);
}
代码示例来源:origin: org.omnifaces/omnipersistence
private static void collectJoins(Path<?> path, Map<String, Path<?>> joins) {
if (path instanceof From) {
((From<?, ?>) path).getJoins().forEach(join -> collectJoins(join, joins));
}
if (path instanceof FetchParent) {
try {
((FetchParent<?, ?>) path).getFetches().stream().filter(fetch -> fetch instanceof Path).forEach(fetch -> collectJoins((Path<?>) fetch, joins));
}
catch (NullPointerException openJPAWillThrowThisOnEmptyFetches) {
// Ignore and continue.
}
}
if (path instanceof Join) {
joins.put(((Join<?, ?>) path).getAttribute().getName(), path);
}
else if (path instanceof Fetch) {
joins.put(((Fetch<?, ?>) path).getAttribute().getName(), path);
}
}
代码示例来源:origin: com.introproventures/graphql-jpa-query-schema
private Join<?,?> reuseJoin(From<?, ?> path, String fieldName, boolean outer) {
for (Join<?,?> join : path.getJoins()) {
if (join.getAttribute().getName().equals(fieldName)) {
if ((join.getJoinType() == JoinType.LEFT) == outer) {
//logger.debug("Reusing existing join for field " + fieldName);
return join;
}
}
}
return outer ? path.join(fieldName, JoinType.LEFT) : path.join(fieldName);
}
代码示例来源:origin: org.springframework.data/spring-data-jpa
/**
* Returns an existing join for the given attribute if one already exists or creates a new one if not.
*
* @param from the {@link From} to get the current joins from.
* @param attribute the {@link Attribute} to look for in the current joins.
* @return will never be {@literal null}.
*/
private static Join<?, ?> getOrCreateJoin(From<?, ?> from, String attribute) {
for (Join<?, ?> join : from.getJoins()) {
boolean sameName = join.getAttribute().getName().equals(attribute);
if (sameName && join.getJoinType().equals(JoinType.LEFT)) {
return join;
}
}
return from.join(attribute, JoinType.LEFT);
}
代码示例来源:origin: org.apache.openejb.patch/openjpa-persistence
protected void evalAccessPaths(QueryExpressions exps, ExpressionFactory factory, CriteriaQueryImpl<?> q) {
Set<ClassMetaData> metas = new HashSet<ClassMetaData>();
MetamodelImpl metamodel = q.getMetamodel();
for (Root<?> root : q.getRoots()) {
metas.add(((AbstractManagedType<?>)root.getModel()).meta);
for (Join<?,?> join : root.getJoins()) {
Class<?> cls = join.getAttribute().getJavaType();
if (join.getAttribute().isAssociation()) {
ClassMetaData meta = metamodel.getRepository().getMetaData(cls, null, true);
PersistenceType type = MetamodelImpl.getPersistenceType(meta);
if (type == PersistenceType.ENTITY || type == PersistenceType.EMBEDDABLE)
metas.add(meta);
}
}
for (Fetch<?,?> fetch : root.getFetches()) {
metas.add(metamodel.getRepository().getCachedMetaData(fetch.getAttribute().getJavaType()));
}
}
exps.accessPath = metas.toArray(new ClassMetaData[metas.size()]);
}
代码示例来源:origin: org.apache.openejb.patch/openjpa
protected void evalAccessPaths(QueryExpressions exps, ExpressionFactory factory, CriteriaQueryImpl<?> q) {
Set<ClassMetaData> metas = new HashSet<ClassMetaData>();
MetamodelImpl metamodel = q.getMetamodel();
for (Root<?> root : q.getRoots()) {
metas.add(((AbstractManagedType<?>)root.getModel()).meta);
for (Join<?,?> join : root.getJoins()) {
Class<?> cls = join.getAttribute().getJavaType();
if (join.getAttribute().isAssociation()) {
ClassMetaData meta = metamodel.getRepository().getMetaData(cls, null, true);
PersistenceType type = MetamodelImpl.getPersistenceType(meta);
if (type == PersistenceType.ENTITY || type == PersistenceType.EMBEDDABLE)
metas.add(meta);
}
}
for (Fetch<?,?> fetch : root.getFetches()) {
metas.add(metamodel.getRepository().getCachedMetaData(fetch.getAttribute().getJavaType()));
}
}
exps.accessPath = metas.toArray(new ClassMetaData[metas.size()]);
}
代码示例来源:origin: org.jboss.pressgang.ccms/pressgang-ccms-query
/**
* Copy Joins
*
* @param from source Join
* @param to destination Join
*/
public static void copyJoins(From<?, ?> from, From<?, ?> to) {
for (Join<?, ?> j : from.getJoins()) {
Join<?, ?> toJoin = to.join(j.getAttribute().getName(), j.getJoinType());
toJoin.alias(getOrCreateAlias(j));
copyJoins(j, toJoin);
}
for (Fetch<?, ?> f : from.getFetches()) {
Fetch<?, ?> toFetch = to.fetch(f.getAttribute().getName());
copyFetches(f, toFetch);
}
}
内容来源于网络,如有侵权,请联系作者删除!