PageRenderTime 131ms CodeModel.GetById 24ms RepoModel.GetById 17ms app.codeStats 0ms

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

http://datanucleus-appengine.googlecode.com/
Java | 171 lines | 115 code | 38 blank | 18 comment | 0 complexity | ccc234d284bc6edbce633cf40ba7c1f8 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 javax.jdo.annotations.IdGeneratorStrategy;
  19. import javax.jdo.annotations.Inheritance;
  20. import javax.jdo.annotations.PersistenceCapable;
  21. import javax.jdo.annotations.Persistent;
  22. import javax.jdo.annotations.PrimaryKey;
  23. /**
  24. * @author Max Ross <max.ross@gmail.com>
  25. */
  26. public class UnidirectionalOneToOneSubclassesJDO {
  27. @PersistenceCapable(detachable = "true")
  28. @Inheritance(customStrategy = "complete-table")
  29. public static class SuperParentWithSuperChild {
  30. @PrimaryKey
  31. @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  32. private Long id;
  33. private String superParentString;
  34. @Persistent(dependent = "true")
  35. private SuperChild superChild;
  36. public Long getId() {
  37. return id;
  38. }
  39. public void setId(Long id) {
  40. this.id = id;
  41. }
  42. public String getSuperParentString() {
  43. return superParentString;
  44. }
  45. public void setSuperParentString(String superParentString) {
  46. this.superParentString = superParentString;
  47. }
  48. public SuperChild getSuperParentSuperChild() {
  49. return superChild;
  50. }
  51. public void setSuperParentSuperChild(SuperChild superChild) {
  52. this.superChild = superChild;
  53. }
  54. }
  55. @PersistenceCapable(detachable = "true")
  56. @Inheritance(customStrategy = "complete-table")
  57. public static class SuperParentWithSubChild {
  58. @PrimaryKey
  59. @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  60. private Long id;
  61. private String superParentString;
  62. @Persistent(dependent = "true")
  63. private SubChild subChild;
  64. public Long getId() {
  65. return id;
  66. }
  67. public String getSuperParentString() {
  68. return superParentString;
  69. }
  70. public void setSuperParentString(String superParentString) {
  71. this.superParentString = superParentString;
  72. }
  73. public void setId(Long id) {
  74. this.id = id;
  75. }
  76. public SubChild getSuperParentSubChild() {
  77. return subChild;
  78. }
  79. public void setSuperParentSubChild(SubChild subChild) {
  80. this.subChild = subChild;
  81. }
  82. }
  83. @PersistenceCapable(detachable = "true")
  84. public static class SubParentWithSuperChild extends SuperParentWithSuperChild {
  85. private String subParentString;
  86. public String getSubParentString() {
  87. return subParentString;
  88. }
  89. public void setSubParentString(String subParentString) {
  90. this.subParentString = subParentString;
  91. }
  92. }
  93. @PersistenceCapable(detachable = "true")
  94. public static class SubParentWithSubChild extends SuperParentWithSubChild {
  95. private String subParentString;
  96. public String getSubParentString() {
  97. return subParentString;
  98. }
  99. public void setSubParentString(String subParentString) {
  100. this.subParentString = subParentString;
  101. }
  102. }
  103. @PersistenceCapable(detachable = "true")
  104. @Inheritance(customStrategy = "complete-table")
  105. public static class SuperChild {
  106. @PrimaryKey
  107. @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  108. private Key id;
  109. private String aString;
  110. public Key getId() {
  111. return id;
  112. }
  113. public void setId(Key id) {
  114. this.id = id;
  115. }
  116. public String getAString() {
  117. return aString;
  118. }
  119. public void setAString(String aString) {
  120. this.aString = aString;
  121. }
  122. }
  123. @PersistenceCapable(detachable = "true")
  124. public static class SubChild extends SuperChild {
  125. private String bString;
  126. public String getBString() {
  127. return bString;
  128. }
  129. public void setBString(String bString) {
  130. this.bString = bString;
  131. }
  132. }
  133. }