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


Java OneToMany.mappedBy方法代碼示例

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


在下文中一共展示了OneToMany.mappedBy方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: extractMetadata

import javax.persistence.OneToMany; //導入方法依賴的package包/類
public ColumnsBuilder extractMetadata() {
	columns = null;
	joinColumns = buildExplicitJoinColumns(property, inferredData);


	if ( property.isAnnotationPresent( Column.class ) || property.isAnnotationPresent( Formula.class ) ) {
		Column ann = property.getAnnotation( Column.class );
		Formula formulaAnn = property.getAnnotation( Formula.class );
		columns = Ejb3Column.buildColumnFromAnnotation(
				new Column[] { ann }, formulaAnn, nullability, propertyHolder, inferredData,
				entityBinder.getSecondaryTables(), mappings
		);
	}
	else if ( property.isAnnotationPresent( Columns.class ) ) {
		Columns anns = property.getAnnotation( Columns.class );
		columns = Ejb3Column.buildColumnFromAnnotation(
				anns.columns(), null,
				nullability, propertyHolder, inferredData, entityBinder.getSecondaryTables(),
				mappings
		);
	}

	//set default values if needed
	if ( joinColumns == null &&
			( property.isAnnotationPresent( ManyToOne.class )
					|| property.isAnnotationPresent( OneToOne.class ) )
			) {
		joinColumns = buildDefaultJoinColumnsForXToOne(property, inferredData);
	}
	else if ( joinColumns == null &&
			( property.isAnnotationPresent( OneToMany.class )
					|| property.isAnnotationPresent( ElementCollection.class )
			) ) {
		OneToMany oneToMany = property.getAnnotation( OneToMany.class );
		String mappedBy = oneToMany != null ?
				oneToMany.mappedBy() :
				"";
		joinColumns = Ejb3JoinColumn.buildJoinColumns(
				null,
				mappedBy, entityBinder.getSecondaryTables(),
				propertyHolder, inferredData.getPropertyName(), mappings
		);
	}
	else if ( joinColumns == null && property.isAnnotationPresent( org.hibernate.annotations.Any.class ) ) {
		throw new AnnotationException( "@Any requires an explicit @JoinColumn(s): "
				+ BinderHelper.getPath( propertyHolder, inferredData ) );
	}
	if ( columns == null && !property.isAnnotationPresent( ManyToMany.class ) ) {
		//useful for collection of embedded elements
		columns = Ejb3Column.buildColumnFromAnnotation(
				null, null,
				nullability, propertyHolder, inferredData, entityBinder.getSecondaryTables(), mappings
		);
	}

	if ( nullability == Nullability.FORCED_NOT_NULL ) {
		//force columns to not null
		for (Ejb3Column col : columns ) {
			col.forceNotNull();
		}
	}
	return this;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:64,代碼來源:ColumnsBuilder.java


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