當前位置: 首頁>>代碼示例>>Java>>正文


Java ManyToMany類代碼示例

本文整理匯總了Java中javax.persistence.ManyToMany的典型用法代碼示例。如果您正苦於以下問題:Java ManyToMany類的具體用法?Java ManyToMany怎麽用?Java ManyToMany使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ManyToMany類屬於javax.persistence包,在下文中一共展示了ManyToMany類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getMappedBy

import javax.persistence.ManyToMany; //導入依賴的package包/類
private String getMappedBy(MetaAttribute attr) {
	ManyToMany manyManyAnnotation = attr.getAnnotation(ManyToMany.class);
	OneToMany oneManyAnnotation = attr.getAnnotation(OneToMany.class);
	OneToOne oneOneAnnotation = attr.getAnnotation(OneToOne.class);
	String mappedBy = null;
	if (manyManyAnnotation != null) {
		mappedBy = manyManyAnnotation.mappedBy();
	}
	if (oneManyAnnotation != null) {
		mappedBy = oneManyAnnotation.mappedBy();
	}
	if (oneOneAnnotation != null) {
		mappedBy = oneOneAnnotation.mappedBy();
	}

	if (mappedBy != null && mappedBy.length() == 0) {
		mappedBy = null;
	}
	return mappedBy;
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:21,代碼來源:JpaMetaFilter.java

示例2: getFieldType

import javax.persistence.ManyToMany; //導入依賴的package包/類
@Override
public Optional<ResourceFieldType> getFieldType(BeanAttributeInformation attributeDesc) {
	Optional<OneToOne> oneToOne = attributeDesc.getAnnotation(OneToOne.class);
	Optional<OneToMany> oneToMany = attributeDesc.getAnnotation(OneToMany.class);
	Optional<ManyToOne> manyToOne = attributeDesc.getAnnotation(ManyToOne.class);
	Optional<ManyToMany> manyToMany = attributeDesc.getAnnotation(ManyToMany.class);
	if (oneToOne.isPresent() || oneToMany.isPresent() || manyToOne.isPresent() || manyToMany.isPresent()) {
		return Optional.of(ResourceFieldType.RELATIONSHIP);
	}

	Optional<Id> id = attributeDesc.getAnnotation(Id.class);
	Optional<EmbeddedId> embeddedId = attributeDesc.getAnnotation(EmbeddedId.class);
	if (id.isPresent() || embeddedId.isPresent()) {
		return Optional.of(ResourceFieldType.ID);
	}
	return Optional.empty();
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:18,代碼來源:JpaResourceFieldInformationProvider.java

示例3: getSerializeType

import javax.persistence.ManyToMany; //導入依賴的package包/類
@Override
public Optional<SerializeType> getSerializeType(BeanAttributeInformation attributeDesc) {
	Optional<OneToMany> oneToMany = attributeDesc.getAnnotation(OneToMany.class);
	if (oneToMany.isPresent()) {
		return toSerializeType(oneToMany.get().fetch());
	}
	Optional<ManyToOne> manyToOne = attributeDesc.getAnnotation(ManyToOne.class);
	if (manyToOne.isPresent()) {
		return toSerializeType(manyToOne.get().fetch());
	}
	Optional<ManyToMany> manyToMany = attributeDesc.getAnnotation(ManyToMany.class);
	if (manyToMany.isPresent()) {
		return toSerializeType(manyToMany.get().fetch());
	}
	Optional<ElementCollection> elementCollection = attributeDesc.getAnnotation(ElementCollection.class);
	if (elementCollection.isPresent()) {
		return toSerializeType(elementCollection.get().fetch());
	}
	return Optional.empty();
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:21,代碼來源:JpaResourceFieldInformationProvider.java

示例4: getPlmVersions

import javax.persistence.ManyToMany; //導入依賴的package包/類
/** @return . */
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "PLM_ISSUE_VERSION", joinColumns = { @JoinColumn(name = "ISSUE_ID", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "VERSION_ID", nullable = false, updatable = false) })
public Set<PlmVersion> getPlmVersions() {
    return this.plmVersions;
}
 
開發者ID:zhaojunfei,項目名稱:lemon,代碼行數:7,代碼來源:PlmIssue.java

示例5: hasAnnotationsOnIdClass

import javax.persistence.ManyToMany; //導入依賴的package包/類
private static boolean hasAnnotationsOnIdClass(XClass idClass) {
//		if(idClass.getAnnotation(Embeddable.class) != null)
//			return true;

		List<XProperty> properties = idClass.getDeclaredProperties( XClass.ACCESS_FIELD );
		for ( XProperty property : properties ) {
			if ( property.isAnnotationPresent( Column.class ) || property.isAnnotationPresent( OneToMany.class ) ||
					property.isAnnotationPresent( ManyToOne.class ) || property.isAnnotationPresent( Id.class ) ||
					property.isAnnotationPresent( GeneratedValue.class ) || property.isAnnotationPresent( OneToOne.class ) ||
					property.isAnnotationPresent( ManyToMany.class )
					) {
				return true;
			}
		}
		List<XMethod> methods = idClass.getDeclaredMethods();
		for ( XMethod method : methods ) {
			if ( method.isAnnotationPresent( Column.class ) || method.isAnnotationPresent( OneToMany.class ) ||
					method.isAnnotationPresent( ManyToOne.class ) || method.isAnnotationPresent( Id.class ) ||
					method.isAnnotationPresent( GeneratedValue.class ) || method.isAnnotationPresent( OneToOne.class ) ||
					method.isAnnotationPresent( ManyToMany.class )
					) {
				return true;
			}
		}
		return false;
	}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:27,代碼來源:AnnotationBinder.java

示例6: appendEntityAttributeName

import javax.persistence.ManyToMany; //導入依賴的package包/類
/**
 * 
 * Append the entity attribute name to the JPQL query statement.
 * 
 * @param jpqlStatement
 * @param jpaEntity
 * @param attribute
 * @throws java.lang.SecurityException 
 * @throws NoSuchFieldException 
 * @throws ClassNotFoundException 
 */
private void appendEntityAttributeName(StringBuilder jpqlStatement, JpaEntity jpaEntity, EntityAttribute attribute, AtomicInteger aliasUnicityKey, AtomicInteger joinAdditionsOffset) throws NoSuchFieldException, java.lang.SecurityException, ClassNotFoundException {
	Class<?> entityClass = Class.forName(jpaEntity.getClassName());
	Field field = entityClass.getDeclaredField(attribute.getAttributeName());
	boolean isJointRelationship = 
			field.getAnnotation(OneToOne.class) != null
			|| field.getAnnotation(OneToMany.class) != null
			|| field.getAnnotation(ManyToOne.class) != null
			|| field.getAnnotation(ManyToMany.class) != null;
	if(isJointRelationship) {
		StringBuilder joinFragment = new StringBuilder();
		Queue<String> objectTreePath = extractDotSeparatedPathFragments(attribute.getPossibleValueLabelAttributePath());
		completeJoinFragment(joinFragment, entityClass, objectTreePath, aliasUnicityKey);
		jpqlStatement.insert(joinAdditionsOffset.get(), joinFragment);
		joinAdditionsOffset.set(joinAdditionsOffset.get() + joinFragment.length());
		jpqlStatement.append(" x").append(aliasUnicityKey.get()).append('.').append(attribute.getPossibleValueLabelAttribute());
	} else {
		jpqlStatement.append(" x.").append(attribute.getAttributeName());
	}
}
 
開發者ID:infiniquery,項目名稱:infiniquery-core,代碼行數:31,代碼來源:DefaultQueryModelService.java

示例7: buildFieldInfo

import javax.persistence.ManyToMany; //導入依賴的package包/類
protected FieldInfo buildFieldInfo(Field field) {
    FieldInfo info = new FieldInfo();
    info.setName(field.getName());
    info.setGenericType(field.getGenericType());
    ManyToMany manyToMany = field.getAnnotation(ManyToMany.class);
    if (manyToMany != null) {
        info.setManyToManyMappedBy(manyToMany.mappedBy());
        info.setManyToManyTargetEntity(manyToMany.targetEntity().getName());
    }
    OneToMany oneToMany = field.getAnnotation(OneToMany.class);
    if (oneToMany != null) {
        info.setOneToManyMappedBy(oneToMany.mappedBy());
        info.setOneToManyTargetEntity(oneToMany.targetEntity().getName());
    }
    MapKey mapKey = field.getAnnotation(MapKey.class);
    if (mapKey != null) {
        info.setMapKey(mapKey.name());
    }
    return info;
}
 
開發者ID:passion1014,項目名稱:metaworks_framework,代碼行數:21,代碼來源:AbstractFieldMetadataProvider.java

示例8: buildFieldInfo

import javax.persistence.ManyToMany; //導入依賴的package包/類
protected FieldInfo buildFieldInfo(Field field) {
    FieldInfo info = new FieldInfo();
    info.setName(field.getName());
    info.setGenericType(field.getGenericType());
    ManyToMany manyToMany = field.getAnnotation(ManyToMany.class);
    if (manyToMany != null) {
        info.setManyToManyMappedBy(manyToMany.mappedBy());
        info.setManyToManyTargetEntity(manyToMany.targetEntity().getName());
    }
    OneToMany oneToMany = field.getAnnotation(OneToMany.class);
    if (oneToMany != null) {
        info.setOneToManyMappedBy(oneToMany.mappedBy());
        info.setOneToManyTargetEntity(oneToMany.targetEntity().getName());
    }
    return info;
}
 
開發者ID:passion1014,項目名稱:metaworks_framework,代碼行數:17,代碼來源:AbstractFieldPersistenceProvider.java

示例9: mappedByAnything

import javax.persistence.ManyToMany; //導入依賴的package包/類
private Annotation mappedByAnything(String property) {
    Field field = findField(property);
    Annotation relationAnnotation = null;

    relationAnnotation = field.getAnnotation(ManyToMany.class);
    if (relationAnnotation != null) {
        return relationAnnotation;
    }

    relationAnnotation = field.getAnnotation(OneToOne.class);
    if (relationAnnotation != null) {
        return relationAnnotation;
    }

    relationAnnotation = field.getAnnotation(OneToMany.class);
    if (relationAnnotation != null) {
        return relationAnnotation;
    }

    relationAnnotation = field.getAnnotation(ManyToOne.class);
    if (relationAnnotation != null) {
        return relationAnnotation;
    }

    return null;
}
 
開發者ID:jurgendl,項目名稱:hql-builder,代碼行數:27,代碼來源:EntityRelationHelper.java

示例10: getChildren

import javax.persistence.ManyToMany; //導入依賴的package包/類
@ReadPermission(expression = "allow all OR deny all")
@UpdatePermission(expression = "allow all OR deny all")
// Hibernate
@ManyToMany(
        targetEntity = Child.class,
        cascade = { CascadeType.PERSIST, CascadeType.MERGE }
)
@JoinTable(
        name = "Parent_Child",
        joinColumns = @JoinColumn(name = "parent_id"),
        inverseJoinColumns = @JoinColumn(name = "child_id")
)
@NotNull
public Set<Child> getChildren() {
    return children;
}
 
開發者ID:yahoo,項目名稱:elide,代碼行數:17,代碼來源:Parent.java

示例11: anyAnnotation

import javax.persistence.ManyToMany; //導入依賴的package包/類
private Annotation anyAnnotation(Field field) {
    Annotation annotation = null;

    annotation = field.getAnnotation(ManyToMany.class);
    if (annotation != null) {
        return annotation;
    }

    annotation = field.getAnnotation(OneToOne.class);
    if (annotation != null) {
        return annotation;
    }

    annotation = field.getAnnotation(OneToMany.class);
    if (annotation != null) {
        return annotation;
    }

    annotation = field.getAnnotation(ManyToOne.class);
    if (annotation != null) {
        return annotation;
    }

    return null;
}
 
開發者ID:jurgendl,項目名稱:hql-builder,代碼行數:26,代碼來源:EntityRelationHelper.java

示例12: targetEntity

import javax.persistence.ManyToMany; //導入依賴的package包/類
private Class<?> targetEntity(Annotation relationAnnotation) {
    if (relationAnnotation instanceof ManyToMany) {
        return ManyToMany.class.cast(relationAnnotation).targetEntity();
    }

    if (relationAnnotation instanceof OneToOne) {
        return OneToOne.class.cast(relationAnnotation).targetEntity();
    }

    if (relationAnnotation instanceof OneToMany) {
        return OneToMany.class.cast(relationAnnotation).targetEntity();
    }

    if (relationAnnotation instanceof ManyToOne) {
        return ManyToOne.class.cast(relationAnnotation).targetEntity();
    }

    return null;
}
 
開發者ID:jurgendl,項目名稱:hql-builder,代碼行數:20,代碼來源:EntityRelationHelper.java

示例13: needsToCascade

import javax.persistence.ManyToMany; //導入依賴的package包/類
private static boolean needsToCascade(Field field) {
    Class<?> fieldtype = field.getType();
    if (!DomainObject.class.isAssignableFrom(fieldtype))
        return false;
    Annotation ann;
    CascadeType[] cascades = null;
    ann = field.getAnnotation(OneToOne.class);
    if (ann != null) {
        cascades = ((OneToOne) ann).cascade();
    } else {
        ann = field.getAnnotation(OneToMany.class);
        if (ann != null) {
            cascades = ((OneToMany) ann).cascade();
        } else {
            ann = field.getAnnotation(ManyToOne.class);
            if (ann != null) {
                cascades = ((ManyToOne) ann).cascade();
            } else {
                ann = field.getAnnotation(ManyToMany.class);
                if (ann != null) {
                    cascades = ((ManyToMany) ann).cascade();
                }
            }
        }
    }
    if (cascades == null)
        return false;
    for (CascadeType cas : cascades) {
        if ((cas == CascadeType.ALL) || (cas == CascadeType.MERGE)
                || (cas == CascadeType.PERSIST)
                || (cas == CascadeType.REMOVE)) {
            return true;
        }
    }
    return false;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:37,代碼來源:ReflectiveClone.java

示例14: getOppositeName

import javax.persistence.ManyToMany; //導入依賴的package包/類
@Override
public Optional<String> getOppositeName(BeanAttributeInformation attributeDesc) {
	Optional<OneToMany> oneToMany = attributeDesc.getAnnotation(OneToMany.class);
	if (oneToMany.isPresent()) {
		return Optional.ofNullable(StringUtils.emptyToNull(oneToMany.get().mappedBy()));
	}
	Optional<ManyToMany> manyToMany = attributeDesc.getAnnotation(ManyToMany.class);
	if (manyToMany.isPresent()) {
		return Optional.ofNullable(StringUtils.emptyToNull(manyToMany.get().mappedBy()));
	}
	return Optional.empty();
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:13,代碼來源:JpaResourceFieldInformationProvider.java

示例15: isManyToMany

import javax.persistence.ManyToMany; //導入依賴的package包/類
public boolean isManyToMany()
{
	if( isManyToMany == null )
	{
		isManyToMany = getAnnotation(ManyToMany.class) != null;
	}
	return isManyToMany;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:9,代碼來源:Property.java


注:本文中的javax.persistence.ManyToMany類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。