@Override
	public List<E> execute() {
		logger.fine("Executing [AppEngineGetList] command");
		Class<E> type = metamodel.type();
		Query query = new Query(Translation.toKind(type));
		QueryRestriction restriction = new QueryRestriction();
		Set<Filter<?>> subfilters = new HashSet<Filter<?>>();
		
		for (Filter<?> filter : filters) {
			if (restriction.restricted(filter)) {
				subfilters.add(filter);
			} else {
				Property<?, ?> property = filter.property();
				String name = (property.parent() instanceof EmbeddedProperty) 
						? property.parent().name() + "." + property.name() : property.name();
				boolean key = false;
				
				if (name.equals(Entities.keyField(type).getName())) {
					name = Entity.KEY_RESERVED_PROPERTY;
					key = true;
				}
				
				if (filter instanceof ComparableFilter<?>) {
					ComparableFilter<?> comparableFilter = (ComparableFilter<?>) filter;
					Object value = comparableFilter.value();
					
					if (key) {
						value = Keys.create(Translation.toKind(type), value);
					}
					
					query.setFilter(new Query.FilterPredicate(
							name, Translation.toFilterOperator(comparableFilter.operator()), value));
				} else if (filter instanceof InFilter<?>) {
					InFilter<?> inFilter = (InFilter<?>) filter;
					List<?> values = inFilter.values();
					
					if (key) {
						List<Object> list = new ArrayList<Object>();
						
						for (Object value : values) {
							list.add(Keys.create(Translation.toKind(type), value));
						}
						
						values = list;
					}
					
					query.setFilter(new Query.FilterPredicate(name, FilterOperator.IN, values));
				}
			}
		}
		
		final List<Order<?, ?>> suborders = new ArrayList<Order<?, ?>>();
		
		for (Order<?, ?> order : orders) {
			if (restriction.restricted(order)) {
				suborders.add(order);
			} else {
				Property<?, ?> property = order.property();
				String name = (property.parent() instanceof EmbeddedProperty) 
						? property.parent().name() + "." + property.name() : property.name();
				query.addSort(name, Translation.toSortDirection(order.direction()));
			}
		}
		
		FetchOptions options = FetchOptions.Builder.withOffset(0);
		
		if (subfilters.isEmpty() && suborders.isEmpty()) {
			// Optimization: If all of the specified filters are not restricted, 
			// establishes the offset and the limit at the query execution.
			options = FetchOptions.Builder.withOffset(offset);
			
			if (Integer.MAX_VALUE - limit >= offset) {
				options.limit(limit);
			}
		}
		
		int count = 0;
		List<E> result = new ArrayList<E>();
		
		for (Entity entity : session.datastore().query(query.setKeysOnly(), options)) {
			E e = session.get(type, entity.getKey());
			Iterator<Filter<?>> iterator = subfilters.iterator();
			boolean matches = true;
			
			while (iterator.hasNext()) {
				if (!iterator.next().matches(e)) {
					matches = false;
					break;
				}
			}
			
			if (matches) {
				result.add(e);
				count++;
				
				if (count >= limit) {
					break;
				}
			}
		}
		
		if (!suborders.isEmpty()) {
			Collections.sort(result, new Comparator<E>() {

				@SuppressWarnings("unchecked")
				@Override
				public int compare(E entity1, E entity2) {
					int compare = 0;
					
					for (Order<?, ?> o : suborders) {
						Order<E, ?> order = (Order<E, ?>) o;
						compare = order.compare(entity1, entity2);
						
						if (order.direction() == Order.Direction.DESC) {
							compare = compare * -1;
						}
						
						if (compare != 0) {
							return compare;
						}
					}
					
					return compare;
				};
				
			});
		}
		
		if (subfilters.isEmpty()) {
			return result;
		} else {
			int offset = this.offset;
			
			if (offset > result.size()) {
				offset = result.size() - 1;
			}
			
			int limit = offset + this.limit;
			
			if (limit > result.size()) {
				limit = result.size();
			}
			
			return result.subList(offset, limit);
		}
	}
@ Override public List < E > execute ( ) { logger . fine ( "Executing [AppEngineGetList] command" ) ; Class < E > type = metamodel . type ( ) ; Query query = new Query ( Translation . toKind ( type ) ) ; QueryRestriction restriction = new QueryRestriction ( ) ; Set < Filter < ? > > subfilters = new HashSet < Filter < ? > > ( ) ; for ( Filter < ? > filter : filters ) { if ( restriction . restricted ( filter ) ) { subfilters . add ( filter ) ; } else { Property < ? , ? > property = filter . property ( ) ; String name = ( property . parent ( ) instanceof EmbeddedProperty ) ? property . parent ( ) . name ( ) + "." + property . name ( ) : property . name ( ) ; boolean key = false ; if ( name . equals ( Entities . keyField ( type ) . getName ( ) ) ) { name = Entity . KEY_RESERVED_PROPERTY ; key = true ; } if ( filter instanceof ComparableFilter < ? > ) { ComparableFilter < ? > comparableFilter = ( ComparableFilter < ? > ) filter ; Object value = comparableFilter . value ( ) ; if ( key ) { value = Keys . create ( Translation . toKind ( type ) , value ) ; } query . setFilter ( new Query . FilterPredicate ( name , Translation . toFilterOperator ( comparableFilter . operator ( ) ) , value ) ) ; } else if ( filter instanceof InFilter < ? > ) { InFilter < ? > inFilter = ( InFilter < ? > ) filter ; List < ? > values = inFilter . values ( ) ; if ( key ) { List < Object > list = new ArrayList < Object > ( ) ; for ( Object value : values ) { list . add ( Keys . create ( Translation . toKind ( type ) , value ) ) ; } values = list ; } query . setFilter ( new Query . FilterPredicate ( name , FilterOperator . IN , values ) ) ; } } } final List < Order < ? , ? > > suborders = new ArrayList < Order < ? , ? > > ( ) ; for ( Order < ? , ? > order : orders ) { if ( restriction . restricted ( order ) ) { suborders . add ( order ) ; } else { Property < ? , ? > property = order . property ( ) ; String name = ( property . parent ( ) instanceof EmbeddedProperty ) ? property . parent ( ) . name ( ) + "." + property . name ( ) : property . name ( ) ; query . addSort ( name , Translation . toSortDirection ( order . direction ( ) ) ) ; } } FetchOptions options = FetchOptions . Builder . withOffset ( 0 ) ; if ( subfilters . isEmpty ( ) && suborders . isEmpty ( ) ) { options = FetchOptions . Builder . withOffset ( offset ) ; if ( Integer . MAX_VALUE - limit >= offset ) { options . limit ( limit ) ; } } int count = 0 ; List < E > result = new ArrayList < E > ( ) ; for ( Entity entity : session . datastore ( ) . query ( query . setKeysOnly ( ) , options ) ) { E e = session . get ( type , entity . getKey ( ) ) ; Iterator < Filter < ? > > iterator = subfilters . iterator ( ) ; boolean matches = true ; while ( iterator . hasNext ( ) ) { if ( ! iterator . next ( ) . matches ( e ) ) { matches = false ; break ; } } if ( matches ) { result . add ( e ) ; count ++ ; if ( count >= limit ) { break ; } } } if ( ! suborders . isEmpty ( ) ) { Collections . sort ( result , new Comparator < E > ( ) { @ SuppressWarnings ( "unchecked" ) @ Override public int compare ( E entity1 , E entity2 ) { int compare = 0 ; for ( Order < ? , ? > o : suborders ) { Order < E , ? > order = ( Order < E , ? > ) o ; compare = order . compare ( entity1 , entity2 ) ; if ( order . direction ( ) == Order . Direction . DESC ) { compare = compare * - 1 ; } if ( compare != 0 ) { return compare ; } } return compare ; } ; } ) ; } if ( subfilters . isEmpty ( ) ) { return result ; } else { int offset = this . offset ; if ( offset > result . size ( ) ) { offset = result . size ( ) - 1 ; } int limit = offset + this . limit ; if ( limit > result . size ( ) ) { limit = result . size ( ) ; } return result . subList ( offset , limit ) ; } }
Executes {@code GetList} with {@code AppEngineDatastoreSession}.

@return The entities match to the specified {@code Filter}s in the
specified range ordered by the specified sort orders as a {@code List}
view.