PageRenderTime 65ms CodeModel.GetById 21ms RepoModel.GetById 2ms app.codeStats 0ms

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

http://datanucleus-appengine.googlecode.com/
Java | 181 lines | 124 code | 39 blank | 18 comment | 0 complexity | 255a9d25db72e992ee6fed3f74b6966e MD5 | raw file
Possible License(s): Apache-2.0
  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.test;
  17. import com.google.appengine.api.datastore.Key;
  18. import java.util.ArrayList;
  19. import java.util.List;
  20. import javax.jdo.annotations.Element;
  21. import javax.jdo.annotations.Extension;
  22. import javax.jdo.annotations.IdGeneratorStrategy;
  23. import javax.jdo.annotations.Inheritance;
  24. import javax.jdo.annotations.Order;
  25. import javax.jdo.annotations.PersistenceCapable;
  26. import javax.jdo.annotations.Persistent;
  27. import javax.jdo.annotations.PrimaryKey;
  28. /**
  29. * @author Max Ross <max.ross@gmail.com>
  30. */
  31. public class UnidirectionalOneToManySubclassesJDO {
  32. @PersistenceCapable(detachable = "true")
  33. @Inheritance(customStrategy = "complete-table")
  34. public static class SuperParentWithSuperChild {
  35. @PrimaryKey
  36. @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  37. private Long id;
  38. private String superParentString;
  39. @Element(dependent = "true")
  40. @Order(extensions = @Extension(vendorName = "datanucleus", key="list-ordering", value="aString DESC"))
  41. private List<SuperChild> superChildren = new ArrayList<SuperChild>();
  42. public Long getId() {
  43. return id;
  44. }
  45. public void setId(Long id) {
  46. this.id = id;
  47. }
  48. public String getSuperParentString() {
  49. return superParentString;
  50. }
  51. public void setSuperParentString(String superParentString) {
  52. this.superParentString = superParentString;
  53. }
  54. public List<SuperChild> getSuperParentSuperChildren() {
  55. return superChildren;
  56. }
  57. public void setSuperParentSuperChildren(
  58. List<SuperChild> superChildren) {
  59. this.superChildren = superChildren;
  60. }
  61. }
  62. @PersistenceCapable(detachable = "true")
  63. @Inheritance(customStrategy = "complete-table")
  64. public static class SuperParentWithSubChild {
  65. @PrimaryKey
  66. @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  67. private Long id;
  68. private String superParentString;
  69. @Element(dependent = "true")
  70. @Order(extensions = @Extension(vendorName = "datanucleus", key="list-ordering", value="bString DESC, aString ASC"))
  71. private List<SubChild> subChildren = new ArrayList<SubChild>();
  72. public Long getId() {
  73. return id;
  74. }
  75. public String getSuperParentString() {
  76. return superParentString;
  77. }
  78. public void setSuperParentString(String superParentString) {
  79. this.superParentString = superParentString;
  80. }
  81. public void setId(Long id) {
  82. this.id = id;
  83. }
  84. public List<SubChild> getSuperParentSubChildren() {
  85. return subChildren;
  86. }
  87. public void setSuperParentSubChildren(
  88. List<SubChild> subChildren) {
  89. this.subChildren = subChildren;
  90. }
  91. }
  92. @PersistenceCapable(detachable = "true")
  93. public static class SubParentWithSuperChild extends SuperParentWithSuperChild {
  94. private String subParentString;
  95. public String getSubParentString() {
  96. return subParentString;
  97. }
  98. public void setSubParentString(String subParentString) {
  99. this.subParentString = subParentString;
  100. }
  101. }
  102. @PersistenceCapable(detachable = "true")
  103. public static class SubParentWithSubChild extends SuperParentWithSubChild {
  104. private String subParentString;
  105. public String getSubParentString() {
  106. return subParentString;
  107. }
  108. public void setSubParentString(String subParentString) {
  109. this.subParentString = subParentString;
  110. }
  111. }
  112. @PersistenceCapable(detachable = "true")
  113. @Inheritance(customStrategy = "complete-table")
  114. public static class SuperChild {
  115. @PrimaryKey
  116. @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  117. private Key id;
  118. private String aString;
  119. public Key getId() {
  120. return id;
  121. }
  122. public void setId(Key id) {
  123. this.id = id;
  124. }
  125. public String getAString() {
  126. return aString;
  127. }
  128. public void setAString(String aString) {
  129. this.aString = aString;
  130. }
  131. }
  132. @PersistenceCapable(detachable = "true")
  133. public static class SubChild extends SuperChild {
  134. private String bString;
  135. public String getBString() {
  136. return bString;
  137. }
  138. public void setBString(String bString) {
  139. this.bString = bString;
  140. }
  141. }
  142. }