Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add query which returns limited number of results

  • Loading branch information...
commit cd2868e1818ed13f7d5e9f94b332854e4566d918 2 parents 016c79c + 0b27b39
@grze grze authored
View
2  clc/modules/msgs/src/main/java/com/eucalyptus/component/Faults.java
@@ -492,7 +492,7 @@ public CheckException apply( final ServiceStatusType input ) {
public static Collection<CheckException> lookup( final ServiceConfiguration config ) {
final EntityTransaction db = Entities.get( CheckException.class );
try {
- final List<CheckException> res = Entities.query( new CheckException( config.getName( ) ) );
+ final List<CheckException> res = Entities.query( new CheckException( config.getName( ) ), true, 1 );
db.commit( );
return res;
} catch ( final Exception ex ) {
View
15 clc/modules/msgs/src/main/java/com/eucalyptus/entities/Entities.java
@@ -233,6 +233,21 @@ public static EntityTransaction get( final Object obj ) {
return Lists.newArrayList( Sets.newHashSet( resultList ) );
}
+ @SuppressWarnings( { "unchecked", "cast" } )
+ public static <T> List<T> query( final T example, final boolean readOnly, final int maxResults ) {
+ final Example qbe = Example.create( example ).enableLike( MatchMode.EXACT );
+ final List<T> resultList = ( List<T> ) getTransaction( example ).getTxState( ).getSession( )
+ .createCriteria( example.getClass( ) )
+ .setReadOnly( readOnly )
+ .setResultTransformer( Criteria.DISTINCT_ROOT_ENTITY )
+ .setCacheable( true )
+ .add( qbe )
+ .setMaxResults( maxResults )
+ .setFetchSize( maxResults )
+ .list( );
+ return Lists.newArrayList( Sets.newHashSet( resultList ) );
+ }
+
public static <T> T uniqueResult( final T example ) throws TransactionException, NoSuchElementException {
try {
final Object pk = resolvePrimaryKey( example );
Please sign in to comment.
Something went wrong with that request. Please try again.