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

http://datanucleus-appengine.googlecode.com/ · Java · 105 lines · 66 code · 21 blank · 18 comment · 0 complexity · 2c8c11140a60889d91f48856e0f22bff 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.List;
  17. import javax.jdo.annotations.Element;
  18. import javax.jdo.annotations.IdGeneratorStrategy;
  19. import javax.jdo.annotations.PersistenceCapable;
  20. import javax.jdo.annotations.Persistent;
  21. import javax.jdo.annotations.PrimaryKey;
  22. /**
  23. * @author Max Ross <maxr@google.com>
  24. */
  25. @PersistenceCapable(detachable = "true")
  26. public class HasMultipleBidirChildrenJDO {
  27. @PrimaryKey
  28. @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  29. private Long id;
  30. @Persistent(mappedBy = "parent")
  31. @Element(dependent = "true")
  32. private List<BidirChild1> child1 = Utils.newArrayList();
  33. @Persistent(mappedBy = "parent")
  34. @Element(dependent = "true")
  35. private List<BidirChild2> child2 = Utils.newArrayList();
  36. public Long getId() {
  37. return id;
  38. }
  39. public List<BidirChild1> getChild1() {
  40. return child1;
  41. }
  42. public void setChild1(List<BidirChild1> child1) {
  43. this.child1 = child1;
  44. }
  45. public List<BidirChild2> getChild2() {
  46. return child2;
  47. }
  48. public void setChild2(List<BidirChild2> child2) {
  49. this.child2 = child2;
  50. }
  51. @PersistenceCapable(detachable = "true")
  52. public static class BidirChild1 {
  53. @PrimaryKey
  54. @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  55. private Key id;
  56. @SuppressWarnings("unused")
  57. @Persistent
  58. private HasMultipleBidirChildrenJDO parent;
  59. public Key getId() {
  60. return id;
  61. }
  62. public void setId(Key id) {
  63. this.id = id;
  64. }
  65. }
  66. @PersistenceCapable(detachable = "true")
  67. public static class BidirChild2 {
  68. @PrimaryKey
  69. @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  70. private Key id;
  71. @SuppressWarnings("unused")
  72. @Persistent
  73. private HasMultipleBidirChildrenJDO parent;
  74. public Key getId() {
  75. return id;
  76. }
  77. public void setId(Key id) {
  78. this.id = id;
  79. }
  80. }
  81. }