HHH-7224: Added metamodel support for Orderable and Sortable sources

This commit is contained in:
John Verhaeg 2012-05-08 11:23:14 -05:00
parent ce2f359d05
commit 4eb057f4de
7 changed files with 261 additions and 356 deletions

View File

@ -53,7 +53,7 @@ public class SetAttributeSourceImpl extends AbstractPluralAttributeSourceImpl im
@Override
public boolean isSorted() {
return StringHelper.isNotEmpty( getComparatorName() );
return StringHelper.isNotEmpty( getComparatorName() ) && !getComparatorName().equals("unsorted");
}
@Override

View File

@ -25,14 +25,11 @@ package org.hibernate.metamodel.spi.binding;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import org.hibernate.AssertionFailure;
import org.hibernate.FetchMode;
import org.hibernate.engine.FetchStyle;
import org.hibernate.engine.FetchTiming;
import org.hibernate.metamodel.spi.domain.PluralAttribute;
import org.hibernate.metamodel.spi.relational.TableSpecification;
import org.hibernate.metamodel.spi.source.MetaAttributeContext;
import org.hibernate.persister.collection.CollectionPersister;
@ -59,7 +56,7 @@ public abstract class AbstractPluralAttributeBinding extends AbstractAttributeBi
private String where;
private String orderBy;
private boolean sorted;
private Comparator comparator;
private Comparator< ? > comparator;
private String comparatorClassName;
private String customLoaderName;
@ -71,7 +68,7 @@ public abstract class AbstractPluralAttributeBinding extends AbstractAttributeBi
private String referencedPropertyName;
private final java.util.Map filters = new HashMap();
private final java.util.Set<String> synchronizedTables = new HashSet<String>();
// private final java.util.Set<String> synchronizedTables = new HashSet<String>();
protected AbstractPluralAttributeBinding(
AttributeBindingContainer container,
@ -289,11 +286,11 @@ public abstract class AbstractPluralAttributeBinding extends AbstractAttributeBi
}
@Override
public Comparator getComparator() {
public Comparator< ? > getComparator() {
return comparator;
}
public void setComparator(Comparator comparator) {
public void setComparator( Comparator< ? > comparator ) {
this.comparator = comparator;
}

View File

@ -23,7 +23,6 @@
*/
package org.hibernate.metamodel.spi.binding;
import java.util.Comparator;
import java.util.List;
import org.hibernate.mapping.PropertyGeneration;
@ -212,7 +211,6 @@ public interface AttributeBindingContainer {
* @param includedInOptimisticLocking
* @param lazy
* @param metaAttributeContext
* @param comparator
*
* @return The attribute binding instance.
*/
@ -223,8 +221,7 @@ public interface AttributeBindingContainer {
String propertyAccessorName,
boolean includedInOptimisticLocking,
boolean lazy,
MetaAttributeContext metaAttributeContext,
Comparator comparator);
MetaAttributeContext metaAttributeContext );
/**
* Seeks out the entity binding that is the root of this component path.

View File

@ -25,7 +25,6 @@ package org.hibernate.metamodel.spi.binding;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -343,8 +342,7 @@ public class CompositeAttributeBinding
String propertyAccessorName,
boolean includedInOptimisticLocking,
boolean lazy,
MetaAttributeContext metaAttributeContext,
Comparator comparator) {
MetaAttributeContext metaAttributeContext ) {
Helper.checkPluralAttributeNature( attribute, PluralAttributeNature.SET );
final SetBinding binding = new SetBinding(
this,
@ -354,8 +352,7 @@ public class CompositeAttributeBinding
propertyAccessorName,
includedInOptimisticLocking,
lazy,
metaAttributeContext,
comparator
metaAttributeContext
);
registerAttributeBinding( attribute.getName(), binding );
return binding;

View File

@ -24,7 +24,6 @@
package org.hibernate.metamodel.spi.binding;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@ -648,8 +647,7 @@ public class EntityBinding implements AttributeBindingContainer {
String propertyAccessorName,
boolean includedInOptimisticLocking,
boolean lazy,
MetaAttributeContext metaAttributeContext,
Comparator comparator) {
MetaAttributeContext metaAttributeContext ) {
Helper.checkPluralAttributeNature( attribute, PluralAttributeNature.SET );
final SetBinding binding = new SetBinding(
this,
@ -659,8 +657,7 @@ public class EntityBinding implements AttributeBindingContainer {
propertyAccessorName,
includedInOptimisticLocking,
lazy,
metaAttributeContext,
comparator
metaAttributeContext
);
registerAttributeBinding( attribute.getName(), binding );
return binding;

View File

@ -23,8 +23,6 @@
*/
package org.hibernate.metamodel.spi.binding;
import java.util.Comparator;
import org.hibernate.metamodel.spi.domain.PluralAttribute;
import org.hibernate.metamodel.spi.source.MetaAttributeContext;
@ -32,7 +30,6 @@ import org.hibernate.metamodel.spi.source.MetaAttributeContext;
* @author Steve Ebersole
*/
public class SetBinding extends AbstractPluralAttributeBinding {
private final Comparator comparator;
public SetBinding(
AttributeBindingContainer container,
@ -42,8 +39,7 @@ public class SetBinding extends AbstractPluralAttributeBinding {
String propertyAccessorName,
boolean includedInOptimisticLocking,
boolean isLazy,
MetaAttributeContext metaAttributeContext,
Comparator comparator) {
MetaAttributeContext metaAttributeContext ) {
super(
container,
attribute,
@ -54,10 +50,5 @@ public class SetBinding extends AbstractPluralAttributeBinding {
isLazy,
metaAttributeContext
);
this.comparator = comparator;
}
public Comparator getComparator() {
return comparator;
}
}