本文整理汇总了Java中org.hibernate.mapping.Collection.setManyToManyOrdering方法的典型用法代码示例。如果您正苦于以下问题:Java Collection.setManyToManyOrdering方法的具体用法?Java Collection.setManyToManyOrdering怎么用?Java Collection.setManyToManyOrdering使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.mapping.Collection
的用法示例。
在下文中一共展示了Collection.setManyToManyOrdering方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bindManyToManySubelements
import org.hibernate.mapping.Collection; //导入方法依赖的package包/类
private static void bindManyToManySubelements(
Collection collection,
Element manyToManyNode,
Mappings model) throws MappingException {
// Bind the where
Attribute where = manyToManyNode.attribute( "where" );
String whereCondition = where == null ? null : where.getValue();
collection.setManyToManyWhere( whereCondition );
// Bind the order-by
Attribute order = manyToManyNode.attribute( "order-by" );
String orderFragment = order == null ? null : order.getValue();
collection.setManyToManyOrdering( orderFragment );
// Bind the filters
Iterator filters = manyToManyNode.elementIterator( "filter" );
if ( ( filters.hasNext() || whereCondition != null ) &&
collection.getFetchMode() == FetchMode.JOIN &&
collection.getElement().getFetchMode() != FetchMode.JOIN ) {
throw new MappingException(
"many-to-many defining filter or where without join fetching " +
"not valid within collection using join fetching [" + collection.getRole() + "]"
);
}
final boolean debugEnabled = LOG.isDebugEnabled();
while ( filters.hasNext() ) {
final Element filterElement = ( Element ) filters.next();
final String name = filterElement.attributeValue( "name" );
String condition = filterElement.getTextTrim();
if ( StringHelper.isEmpty(condition) ) condition = filterElement.attributeValue( "condition" );
if ( StringHelper.isEmpty(condition) ) {
condition = model.getFilterDefinition(name).getDefaultFilterCondition();
}
if ( condition==null) {
throw new MappingException("no filter condition found for filter: " + name);
}
Iterator aliasesIterator = filterElement.elementIterator("aliases");
java.util.Map<String, String> aliasTables = new HashMap<String, String>();
while (aliasesIterator.hasNext()){
Element alias = (Element) aliasesIterator.next();
aliasTables.put(alias.attributeValue("alias"), alias.attributeValue("table"));
}
if ( debugEnabled ) {
LOG.debugf( "Applying many-to-many filter [%s] as [%s] to role [%s]", name, condition, collection.getRole() );
}
String autoAliasInjectionText = filterElement.attributeValue("autoAliasInjection");
boolean autoAliasInjection = StringHelper.isEmpty(autoAliasInjectionText) ? true : Boolean.parseBoolean(autoAliasInjectionText);
collection.addManyToManyFilter(name, condition, autoAliasInjection, aliasTables, null);
}
}
示例2: bindManyToManySubelements
import org.hibernate.mapping.Collection; //导入方法依赖的package包/类
private static void bindManyToManySubelements(
Collection collection,
Element manyToManyNode,
Mappings model) throws MappingException {
// Bind the where
Attribute where = manyToManyNode.attribute( "where" );
String whereCondition = where == null ? null : where.getValue();
collection.setManyToManyWhere( whereCondition );
// Bind the order-by
Attribute order = manyToManyNode.attribute( "order-by" );
String orderFragment = order == null ? null : order.getValue();
collection.setManyToManyOrdering( orderFragment );
// Bind the filters
Iterator filters = manyToManyNode.elementIterator( "filter" );
if ( ( filters.hasNext() || whereCondition != null ) &&
collection.getFetchMode() == FetchMode.JOIN &&
collection.getElement().getFetchMode() != FetchMode.JOIN ) {
throw new MappingException(
"many-to-many defining filter or where without join fetching " +
"not valid within collection using join fetching [" + collection.getRole() + "]"
);
}
while ( filters.hasNext() ) {
final Element filterElement = ( Element ) filters.next();
final String name = filterElement.attributeValue( "name" );
String condition = filterElement.getTextTrim();
if ( StringHelper.isEmpty(condition) ) condition = filterElement.attributeValue( "condition" );
if ( StringHelper.isEmpty(condition) ) {
condition = model.getFilterDefinition(name).getDefaultFilterCondition();
}
if ( condition==null) {
throw new MappingException("no filter condition found for filter: " + name);
}
log.debug(
"Applying many-to-many filter [" + name +
"] as [" + condition +
"] to role [" + collection.getRole() + "]"
);
collection.addManyToManyFilter( name, condition );
}
}