/src/com/google/appengine/datanucleus/query/JPACursorHelper.java

http://datanucleus-appengine.googlecode.com/ · Java · 53 lines · 7 code · 5 blank · 41 comment · 0 complexity · 1af031a55d649b0fce07cf8847ec5bd4 MD5 · raw file

  1. /*
  2. * Copyright (C) 2010 Google Inc
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.google.appengine.datanucleus.query;
  17. import com.google.appengine.api.datastore.Cursor;
  18. import javax.persistence.Query;
  19. /**
  20. * Utilities for working with {@link Cursor} through the JPA
  21. * {@link Query} api.
  22. * <br>
  23. * To add a Cursor to a query, set the Cursor as an extension:
  24. * <blockquote>
  25. * <pre>
  26. * Query q = em.createQuery(Flight.class);
  27. * q.setFirstResult(100);
  28. * q.setMaxResults(100);
  29. * q.setHint(JpaCursorHelper.CURSOR_HINT, cursor);
  30. * List<Flight> flights = q.getResultList();
  31. * </pre>
  32. * </blockquote>
  33. * Note that in this esample {@code cursor} can be either of type
  34. * {@link Cursor} or a {@link String} representation of Cursor obtained by
  35. * calling {@link Cursor#toWebSafeString()}.
  36. *<br>
  37. * To extract a Cursor from a result set, call {@link #getCursor(java.util.List)}
  38. * with the result set as the argument.
  39. *<br>
  40. * This class is part of the public api of the DataNucleus App Engine plugin
  41. * and can be safely used.
  42. *
  43. * @author Max Ross <max.ross@gmail.com>
  44. */
  45. public final class JPACursorHelper extends CursorHelper {
  46. public static final String CURSOR_HINT = QUERY_CURSOR_PROPERTY_NAME;
  47. private JPACursorHelper() {}
  48. }