/tests/com/google/appengine/datanucleus/test/HasOneToManyKeyPkListJDO.java

http://datanucleus-appengine.googlecode.com/ · Java · 57 lines · 29 code · 10 blank · 18 comment · 0 complexity · 7c75a00e483422b61e80a3c178e55761 MD5 · raw file

  1. /**********************************************************************
  2. Copyright (c) 2009 Google Inc.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. **********************************************************************/
  13. package com.google.appengine.datanucleus.test;
  14. import com.google.appengine.api.datastore.Key;
  15. import com.google.appengine.datanucleus.Utils;
  16. import java.util.Collection;
  17. import java.util.List;
  18. import javax.jdo.annotations.Element;
  19. import javax.jdo.annotations.IdGeneratorStrategy;
  20. import javax.jdo.annotations.Order;
  21. import javax.jdo.annotations.PersistenceCapable;
  22. import javax.jdo.annotations.Persistent;
  23. import javax.jdo.annotations.PrimaryKey;
  24. /**
  25. * @author Max Ross <maxr@google.com>
  26. */
  27. @PersistenceCapable(detachable = "true")
  28. public class HasOneToManyKeyPkListJDO implements HasOneToManyKeyPkJDO {
  29. @PrimaryKey
  30. @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  31. private Key key;
  32. @Element(dependent = "true")
  33. @Order(column = "flights_INTEGER_IDX_keypk")
  34. private List<Flight> flights = Utils.newArrayList();
  35. public void addFlight(Flight flight) {
  36. flights.add(flight);
  37. }
  38. public Collection<Flight> getFlights() {
  39. return flights;
  40. }
  41. public Key getId() {
  42. return key;
  43. }
  44. }