org.hibernate.transform
public class: DistinctResultTransformer [javadoc |
source]
java.lang.Object
org.hibernate.transform.BasicTransformerAdapter
org.hibernate.transform.DistinctResultTransformer
All Implemented Interfaces:
Serializable, ResultTransformer
Distinctions the result tuples in the final result based on the defined
equality of the tuples.
Since this transformer is stateless, all instances would be considered equal.
So for optimization purposes we limit it to a single, singleton
instance .
| Field Summary |
|---|
| public static final DistinctResultTransformer | INSTANCE | |
| Method from org.hibernate.transform.DistinctResultTransformer Summary: |
|---|
|
transformList |
| Method from org.hibernate.transform.DistinctResultTransformer Detail: |
public List transformList(List list) {
List result = new ArrayList( list.size() );
Set distinct = new HashSet();
for ( int i = 0; i < list.size(); i++ ) {
Object entity = list.get( i );
if ( distinct.add( new Identity( entity ) ) ) {
result.add( entity );
}
}
if ( log.isDebugEnabled() ) {
log.debug(
"transformed: " +
list.size() + " rows to: " +
result.size() + " distinct results"
);
}
return result;
}
Uniquely distinct each tuple row here. |