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

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

源代码1 项目: lams   文件: CollectionBinder.java
public void setJpaOrderBy(javax.persistence.OrderBy jpaOrderBy) {
	this.jpaOrderBy = jpaOrderBy;
}
 
源代码2 项目: lams   文件: CollectionBinder.java
public void setSqlOrderBy(OrderBy sqlOrderBy) {
	this.sqlOrderBy = sqlOrderBy;
}
 
源代码3 项目: lams   文件: CollectionBinder.java
private void applySortingAndOrdering(Collection collection) {
	boolean hadOrderBy = false;
	boolean hadExplicitSort = false;

	Class<? extends Comparator> comparatorClass = null;

	if ( jpaOrderBy == null && sqlOrderBy == null ) {
		if ( deprecatedSort != null ) {
			LOG.debug( "Encountered deprecated @Sort annotation; use @SortNatural or @SortComparator instead." );
			if ( naturalSort != null || comparatorSort != null ) {
				throw buildIllegalSortCombination();
			}
			hadExplicitSort = deprecatedSort.type() != SortType.UNSORTED;
			if ( deprecatedSort.type() == SortType.NATURAL ) {
				isSortedCollection = true;
			}
			else if ( deprecatedSort.type() == SortType.COMPARATOR ) {
				isSortedCollection = true;
				comparatorClass = deprecatedSort.comparator();
			}
		}
		else if ( naturalSort != null ) {
			if ( comparatorSort != null ) {
				throw buildIllegalSortCombination();
			}
			hadExplicitSort = true;
		}
		else if ( comparatorSort != null ) {
			hadExplicitSort = true;
			comparatorClass = comparatorSort.value();
		}
	}
	else {
		if ( jpaOrderBy != null && sqlOrderBy != null ) {
			throw new AnnotationException(
					String.format(
							"Illegal combination of @%s and @%s on %s",
							javax.persistence.OrderBy.class.getName(),
							OrderBy.class.getName(),
							safeCollectionRole()
					)
			);
		}

		hadOrderBy = true;
		hadExplicitSort = false;

		// we can only apply the sql-based order by up front.  The jpa order by has to wait for second pass
		if ( sqlOrderBy != null ) {
			collection.setOrderBy( sqlOrderBy.clause() );
		}
	}

	if ( isSortedCollection ) {
		if ( ! hadExplicitSort && !hadOrderBy ) {
			throw new AnnotationException(
					"A sorted collection must define and ordering or sorting : " + safeCollectionRole()
			);
		}
	}

	collection.setSorted( isSortedCollection || hadExplicitSort );

	if ( comparatorClass != null ) {
		try {
			collection.setComparator( comparatorClass.newInstance() );
		}
		catch (Exception e) {
			throw new AnnotationException(
					String.format(
							"Could not instantiate comparator class [%s] for %s",
							comparatorClass.getName(),
							safeCollectionRole()
					)
			);
		}
	}
}
 
源代码4 项目: lams   文件: CollectionBinder.java
private String extractHqlOrderBy(javax.persistence.OrderBy jpaOrderBy) {
	if ( jpaOrderBy != null ) {
		return jpaOrderBy.value(); // Null not possible. In case of empty expression, apply default ordering.
	}
	return null; // @OrderBy not found.
}
 
源代码5 项目: lams   文件: ListBinder.java
@Override
public void setSqlOrderBy(OrderBy orderByAnn) {
	if ( orderByAnn != null ) {
		LOG.orderByAnnotationIndexedCollection();
	}
}
 
源代码6 项目: lams   文件: SetBinder.java
@Override
public void setSqlOrderBy(OrderBy orderByAnn) {
	if ( orderByAnn != null ) {
		super.setSqlOrderBy( orderByAnn );
	}
}
 
源代码7 项目: jeewx   文件: CgFormHeadEntity.java
@OneToMany(cascade=CascadeType.REMOVE,mappedBy="table")
@OrderBy(clause="orderNum asc")
public List<CgFormFieldEntity> getColumns() {
	return columns;
}
 
源代码8 项目: jeecg   文件: CgFormHeadEntity.java
@OneToMany(cascade=CascadeType.REMOVE,mappedBy="table")
@OrderBy(clause="orderNum asc")
public List<CgFormFieldEntity> getColumns() {
	return columns;
}
 
 类所在包
 类方法
 同包方法