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


Java OneToMany類代碼示例

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


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

示例1: getMappedBy

import javax.persistence.OneToMany; //導入依賴的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: getSerializeType

import javax.persistence.OneToMany; //導入依賴的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

示例3: getPlanServices

import javax.persistence.OneToMany; //導入依賴的package包/類
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true)
@JoinColumn(name = "user_id", insertable = false, nullable = false, updatable = false)
// MOSCOW
@Fetch(FetchMode.SELECT)
// Это отсечение дублирования при джойне таблици, т.к. в QPlanService есть @OneToOne к QService, и в нем есть @OneToMany к QServiceLang - дублится по
// количеству переводов
// This is the truncation of the duplication when the table joins, since In QPlanService there is @OneToOne to QService, and there is @OneToMany to
// QServiceLang - it is duplicated by the number of translations.
public List<QPlanService> getPlanServices() {
    return planServices;
}
 
開發者ID:bcgov,項目名稱:sbc-qsystem,代碼行數:12,代碼來源:QUser.java

示例4: getStrings

import javax.persistence.OneToMany; //導入依賴的package包/類
@OneToMany(cascade = CascadeType.ALL, mappedBy = "bundle")
@Fetch(value = FetchMode.SELECT)
@MapKey(name = "locale")
public Map<String, LanguageString> getStrings()
{
	return strings;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:8,代碼來源:LanguageBundle.java

示例5: isMappedCollection

import javax.persistence.OneToMany; //導入依賴的package包/類
@Override
public boolean isMappedCollection(CtField field) {
    try {
        return (field.getAnnotation(OneToMany.class) != null ||
                field.getAnnotation(ManyToMany.class) != null ||
                field.getAnnotation(ElementCollection.class) != null);
    }
    catch (ClassNotFoundException e) {
        return false;
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:12,代碼來源:EnhancementTask.java

示例6: needsToCascade

import javax.persistence.OneToMany; //導入依賴的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

示例7: getOppositeName

import javax.persistence.OneToMany; //導入依賴的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

示例8: discoverTypeWithoutReflection

import javax.persistence.OneToMany; //導入依賴的package包/類
private static boolean discoverTypeWithoutReflection(XProperty p) {
	if ( p.isAnnotationPresent( OneToOne.class ) && !p.getAnnotation( OneToOne.class )
			.targetEntity()
			.equals( void.class ) ) {
		return true;
	}
	else if ( p.isAnnotationPresent( OneToMany.class ) && !p.getAnnotation( OneToMany.class )
			.targetEntity()
			.equals( void.class ) ) {
		return true;
	}
	else if ( p.isAnnotationPresent( ManyToOne.class ) && !p.getAnnotation( ManyToOne.class )
			.targetEntity()
			.equals( void.class ) ) {
		return true;
	}
	else if ( p.isAnnotationPresent( ManyToMany.class ) && !p.getAnnotation( ManyToMany.class )
			.targetEntity()
			.equals( void.class ) ) {
		return true;
	}
	else if ( p.isAnnotationPresent( org.hibernate.annotations.Any.class ) ) {
		return true;
	}
	else if ( p.isAnnotationPresent( ManyToAny.class ) ) {
		if ( !p.isCollection() && !p.isArray() ) {
			throw new AnnotationException( "@ManyToAny used on a non collection non array property: " + p.getName() );
		}
		return true;
	}
	else if ( p.isAnnotationPresent( Type.class ) ) {
		return true;
	}
	else if ( p.isAnnotationPresent( Target.class ) ) {
		return true;
	}
	return false;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:39,代碼來源:PropertyContainer.java

示例9: getComments

import javax.persistence.OneToMany; //導入依賴的package包/類
/**
 * Get all comments for current blog entry.
 * 
 * @return List of all comments for current blog entry.
 */
@OneToMany(mappedBy = "blogEntry", fetch = FetchType.LAZY,
        cascade = CascadeType.PERSIST, orphanRemoval = true)
@OrderBy("postedOn")
public List<BlogComment> getComments() {
    return comments;
}
 
開發者ID:fgulan,項目名稱:java-course,代碼行數:12,代碼來源:BlogEntry.java

示例10: getCascadeTypes

import javax.persistence.OneToMany; //導入依賴的package包/類
private CascadeType[] getCascadeTypes(AccessibleObject accessibleObject) {
    CascadeType[] cascadeTypes = null;
    if(accessibleObject.isAnnotationPresent(OneToMany.class)) {
        cascadeTypes = accessibleObject.getAnnotation(OneToMany.class).cascade();
    }else if(accessibleObject.isAnnotationPresent(ManyToOne.class)) {
        cascadeTypes = accessibleObject.getAnnotation(ManyToOne.class).cascade();
    }else if(accessibleObject.isAnnotationPresent(ManyToMany.class)) {
        cascadeTypes = accessibleObject.getAnnotation(ManyToMany.class).cascade();
    }
    return cascadeTypes;
}
 
開發者ID:chaokunyang,項目名稱:jkes,代碼行數:12,代碼來源:EventSupport.java

示例11:

import javax.persistence.OneToMany; //導入依賴的package包/類
@OneToMany(targetEntity = Goods8JPA.class, cascade = REMOVE,
          fetch = EAGER)
@JoinColumn(name = "join_goods_brand_m2o", foreignKey =
@ForeignKey(name = "fk_goods_brand_m2o"))
@JoinTable(name = "jpa_goods_brand_set", foreignKey =
@ForeignKey(name = "fk_jpa_goods_brand_set"))
public Set<Goods8JPA> getGoods8JPASet()
{
    return goods8JPASet;
}
 
開發者ID:SessionFactory,項目名稱:tinyshop8,代碼行數:11,代碼來源:GoodsBrand8JPA.java

示例12: getDiskAcls

import javax.persistence.OneToMany; //導入依賴的package包/類
/** @return . */
@OneToMany(fetch = FetchType.LAZY, mappedBy = "diskShare")
public Set<DiskAcl> getDiskAcls() {
    return this.diskAcls;
}
 
開發者ID:zhaojunfei,項目名稱:lemon,代碼行數:6,代碼來源:DiskShare.java

示例13: getOrderDetails

import javax.persistence.OneToMany; //導入依賴的package包/類
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="product")
public Set<OrderDetail> getOrderDetails() {
    return this.orderDetails;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:5,代碼來源:Product.java

示例14: getEmployees

import javax.persistence.OneToMany; //導入依賴的package包/類
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="office")
public Set<Employee> getEmployees() {
    return this.employees;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:5,代碼來源:Office.java

示例15: getEmployees

import javax.persistence.OneToMany; //導入依賴的package包/類
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER, mappedBy="company")
public Set<Employee> getEmployees() {
    return this.employees;
}
 
開發者ID:amritbhat786,項目名稱:DocIT,代碼行數:5,代碼來源:Company.java


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