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

http://datanucleus-appengine.googlecode.com/ · Java · 55 lines · 27 code · 10 blank · 18 comment · 0 complexity · 0729bcdabf0fc1d586f12797240a532e 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 java.util.ArrayList;
  16. import java.util.List;
  17. import javax.persistence.CascadeType;
  18. import javax.persistence.Entity;
  19. import javax.persistence.GeneratedValue;
  20. import javax.persistence.GenerationType;
  21. import javax.persistence.Id;
  22. import javax.persistence.OneToMany;
  23. /**
  24. * @author Max Ross <maxr@google.com>
  25. */
  26. @Entity
  27. public class HasOneToManyKeyPkListJPA implements HasOneToManyKeyPkJPA {
  28. @Id
  29. @GeneratedValue(strategy=GenerationType.IDENTITY)
  30. private Key id;
  31. @OneToMany(cascade = CascadeType.ALL)
  32. private List<Book> books = new ArrayList<Book>();
  33. public Key getId() {
  34. return id;
  35. }
  36. public List<Book> getBooks() {
  37. return books;
  38. }
  39. public void nullBooks() {
  40. this.books = null;
  41. }
  42. }