类org.hibernate.annotations.Columns源码实例Demo

下面列出了怎么用org.hibernate.annotations.Columns的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: lams   文件: JPAOverriddenAnnotationReader.java
private Columns buildColumns(Element element) {
	List<Element> subelements = element.elements( "column" );
	List<Column> columns = new ArrayList<>( subelements.size() );
	for ( Element subelement : subelements ) {
		columns.add( getColumn( subelement, false, element ) );
	}
	if ( columns.size() > 0 ) {
		AnnotationDescriptor columnsDescr = new AnnotationDescriptor( Columns.class );
		columnsDescr.setValue( "columns", columns.toArray( new Column[columns.size()] ) );
		return AnnotationFactory.create( columnsDescr );
	}
	else {
		return null;
	}
}
 
源代码2 项目: lams   文件: ColumnsBuilder.java
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(),
				buildingContext
		);
	}
	else if ( property.isAnnotationPresent( Columns.class ) ) {
		Columns anns = property.getAnnotation( Columns.class );
		columns = Ejb3Column.buildColumnFromAnnotation(
				anns.columns(),
				null,
				nullability,
				propertyHolder,
				inferredData,
				entityBinder.getSecondaryTables(),
				buildingContext
		);
	}

	//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(),
				buildingContext
		);
	}
	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(),
				buildingContext
		);
	}

	if ( nullability == Nullability.FORCED_NOT_NULL ) {
		//force columns to not null
		for (Ejb3Column col : columns ) {
			col.forceNotNull();
		}
	}
	return this;
}
 
源代码3 项目: lams   文件: CustomizableColumns.java
public Class<? extends Annotation> annotationType() {
	return Columns.class;
}
 
 类所在包
 类方法
 同包方法