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

http://datanucleus-appengine.googlecode.com/ · Java · 87 lines · 51 code · 18 blank · 18 comment · 0 complexity · 8e08c4058cd6c9f9752de1b686202a36 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 org.datanucleus.api.jpa.annotations.Extension;
  15. import java.util.HashSet;
  16. import java.util.Set;
  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 HasOneToManySetJPA implements HasOneToManyJPA {
  28. @Id
  29. @GeneratedValue(strategy = GenerationType.IDENTITY)
  30. @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
  31. private String id;
  32. private String val;
  33. @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
  34. private Set<BidirectionalChildSetJPA> bidirChildren = new HashSet<BidirectionalChildSetJPA>();
  35. @OneToMany(cascade = CascadeType.ALL)
  36. private Set<Book> books = new HashSet<Book>();
  37. @OneToMany(cascade = CascadeType.ALL)
  38. private Set<HasKeyPkJPA> hasKeyPks = new HashSet<HasKeyPkJPA>();
  39. public String getId() {
  40. return id;
  41. }
  42. public Set<BidirectionalChildJPA> getBidirChildren() {
  43. return (Set) bidirChildren;
  44. }
  45. public void nullBidirChildren() {
  46. this.bidirChildren = null;
  47. }
  48. public Set<Book> getBooks() {
  49. return books;
  50. }
  51. public void nullBooks() {
  52. this.books = null;
  53. }
  54. public Set<HasKeyPkJPA> getHasKeyPks() {
  55. return hasKeyPks;
  56. }
  57. public void nullHasKeyPks() {
  58. this.hasKeyPks = null;
  59. }
  60. public String getVal() {
  61. return val;
  62. }
  63. public void setVal(String val) {
  64. this.val = val;
  65. }
  66. }