PageRenderTime 49ms CodeModel.GetById 7ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://datanucleus-appengine.googlecode.com/
Java | 389 lines | 278 code | 96 blank | 15 comment | 0 complexity | 4b7ca894031f06363eaad15328fd2ea4 MD5 | raw file
Possible License(s): Apache-2.0
  1. /**********************************************************************
  2. Copyright (c) 2011 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.test.BidirectionalSingleTableChildListJPA.BidirTopList;
  16. import com.google.appengine.datanucleus.test.BidirectionalSingleTableChildListJPA.BidirTopLongPkList;
  17. import com.google.appengine.datanucleus.test.BidirectionalSingleTableChildListJPA.BidirTopStringPkList;
  18. import com.google.appengine.datanucleus.test.BidirectionalSingleTableChildListJPA.BidirTopUnencodedStringPkList;
  19. import com.google.appengine.datanucleus.test.HasPolymorphicRelationsJPA.HasOneToManyJPA;
  20. import com.google.appengine.datanucleus.test.HasPolymorphicRelationsJPA.HasOneToManyKeyPkJPA;
  21. import com.google.appengine.datanucleus.test.HasPolymorphicRelationsJPA.HasOneToManyLongPkJPA;
  22. import com.google.appengine.datanucleus.test.HasPolymorphicRelationsJPA.HasOneToManyUnencodedStringPkJPA;
  23. import com.google.appengine.datanucleus.test.SubclassesJPA.MappedSuperclassParent;
  24. import com.google.appengine.datanucleus.test.SubclassesJPA.TablePerClass;
  25. import com.google.appengine.datanucleus.test.UnidirectionalSingeTableChildJPA.UnidirTop;
  26. import org.datanucleus.api.jpa.annotations.Extension;
  27. import java.util.ArrayList;
  28. import java.util.Collection;
  29. import java.util.List;
  30. import javax.persistence.CascadeType;
  31. import javax.persistence.Entity;
  32. import javax.persistence.FetchType;
  33. import javax.persistence.GeneratedValue;
  34. import javax.persistence.GenerationType;
  35. import javax.persistence.Id;
  36. import javax.persistence.JoinColumn;
  37. import javax.persistence.OneToMany;
  38. import javax.persistence.OneToOne;
  39. import javax.persistence.OrderBy;
  40. public class HasPolymorphicRelationsListJPA {
  41. @Entity
  42. public static class HasOneToManyListJPA implements HasOneToManyJPA {
  43. @Id
  44. @GeneratedValue(strategy=GenerationType.IDENTITY)
  45. @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
  46. private String id;
  47. private String val;
  48. @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
  49. private List<BidirTopList> bidirChildren = new ArrayList<BidirTopList>();
  50. @OneToMany(cascade = CascadeType.ALL)
  51. private List<UnidirTop> unidirChildren = new ArrayList<UnidirTop>();
  52. @OneToMany(cascade = CascadeType.ALL)
  53. private List<HasKeyPkJPA> hasKeyPks = new ArrayList<HasKeyPkJPA>();
  54. public String getId() {
  55. return id;
  56. }
  57. public List<BidirectionalSingleTableChildJPA.BidirTop> getBidirChildren() {
  58. return (List) bidirChildren;
  59. }
  60. public void nullBidirChildren() {
  61. this.bidirChildren = null;
  62. }
  63. public List<UnidirTop> getUnidirChildren() {
  64. return unidirChildren;
  65. }
  66. public void nullUnidirChildren() {
  67. this.unidirChildren = null;
  68. }
  69. public List<HasKeyPkJPA> getHasKeyPks() {
  70. return hasKeyPks;
  71. }
  72. public void nullHasKeyPks() {
  73. this.hasKeyPks = null;
  74. }
  75. public String getVal() {
  76. return val;
  77. }
  78. public void setVal(String val) {
  79. this.val = val;
  80. }
  81. }
  82. @Entity
  83. public static class HasOneToManyLongPkListJPA implements HasOneToManyLongPkJPA {
  84. @Id
  85. @GeneratedValue(strategy=GenerationType.IDENTITY)
  86. private Long id;
  87. private String val;
  88. @OneToMany(cascade = CascadeType.ALL)
  89. private List<UnidirTop> unidirChildren = new ArrayList<UnidirTop>();
  90. @OneToMany(cascade = CascadeType.ALL)
  91. private List<HasKeyPkJPA> hasKeyPks = new ArrayList<HasKeyPkJPA>();
  92. @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
  93. private List<BidirTopLongPkList> bidirChildren =
  94. new ArrayList<BidirTopLongPkList>();
  95. public Long getId() {
  96. return id;
  97. }
  98. public List<UnidirTop> getUnidirChildren() {
  99. return unidirChildren;
  100. }
  101. public void nullUnidirChildren() {
  102. this.unidirChildren = null;
  103. }
  104. public Collection<BidirectionalSingleTableChildJPA.BidirTopLongPk> getBidirChildren() {
  105. return (List) bidirChildren;
  106. }
  107. public List<HasKeyPkJPA> getHasKeyPks() {
  108. return hasKeyPks;
  109. }
  110. public String getVal() {
  111. return val;
  112. }
  113. public void setVal(String val) {
  114. this.val = val;
  115. }
  116. }
  117. @Entity
  118. public static class HasOneToManyStringPkListJPA {
  119. @Id
  120. private String id;
  121. private String val;
  122. @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
  123. private List<BidirTopStringPkList> bidirChildren =
  124. new ArrayList<BidirTopStringPkList>();
  125. @OneToMany(cascade = CascadeType.ALL)
  126. private List<UnidirTop> unidirChildren = new ArrayList<UnidirTop>();
  127. @OneToMany(cascade = CascadeType.ALL)
  128. private List<HasKeyPkJPA> hasKeyPks = new ArrayList<HasKeyPkJPA>();
  129. public String getId() {
  130. return id;
  131. }
  132. public void setId(String id) {
  133. this.id = id;
  134. }
  135. public List<BidirTopStringPkList> getBidirChildren() {
  136. return (List) bidirChildren;
  137. }
  138. public void nullBidirChildren() {
  139. this.bidirChildren = null;
  140. }
  141. public List<UnidirTop> getUnidirChildren() {
  142. return unidirChildren;
  143. }
  144. public void nullUnidirChildren() {
  145. this.unidirChildren = null;
  146. }
  147. public List<HasKeyPkJPA> getHasKeyPks() {
  148. return hasKeyPks;
  149. }
  150. public void nullHasKeyPks() {
  151. this.hasKeyPks = null;
  152. }
  153. public String getVal() {
  154. return val;
  155. }
  156. public void setVal(String val) {
  157. this.val = val;
  158. }
  159. }
  160. @Entity
  161. public static class HasOneToManyKeyPkListJPA implements HasOneToManyKeyPkJPA {
  162. @Id
  163. @GeneratedValue(strategy=GenerationType.IDENTITY)
  164. private Key id;
  165. @OneToMany(cascade = CascadeType.ALL)
  166. private List<UnidirTop> unidirChildren = new ArrayList<UnidirTop>();
  167. public Key getId() {
  168. return id;
  169. }
  170. public List<UnidirTop> getUnidirChildren() {
  171. return unidirChildren;
  172. }
  173. public void nullUnidirChildren() {
  174. this.unidirChildren = null;
  175. }
  176. }
  177. @Entity
  178. public static class HasOneToManyUnencodedStringPkListJPA implements HasOneToManyUnencodedStringPkJPA {
  179. @Id
  180. private String id;
  181. @OneToMany(cascade = CascadeType.ALL)
  182. private List<UnidirTop> unidirChildren = new ArrayList<UnidirTop>();
  183. @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
  184. private List<BidirTopUnencodedStringPkList> bidirChildren =
  185. new ArrayList<BidirTopUnencodedStringPkList>();
  186. public String getId() {
  187. return id;
  188. }
  189. public void setId(String id) {
  190. this.id = id;
  191. }
  192. public List<UnidirTop> getUnidirChildren() {
  193. return unidirChildren;
  194. }
  195. public void nullUnidirChildren() {
  196. this.unidirChildren = null;
  197. }
  198. public Collection<BidirectionalSingleTableChildJPA.BidirTopUnencodedStringPk> getBidirChildren() {
  199. return (Collection) bidirChildren;
  200. }
  201. }
  202. @Entity
  203. public static class HasOneToManyWithOrderByJPA {
  204. @Id
  205. @GeneratedValue(strategy=GenerationType.IDENTITY)
  206. private Long id;
  207. private String val;
  208. @OneToMany(cascade = CascadeType.ALL)
  209. @OrderBy("name DESC, str ASC")
  210. private List<UnidirTop> unidirByNameAndStr = new ArrayList<UnidirTop>();
  211. @OneToMany(cascade = CascadeType.ALL)
  212. @OrderBy("id DESC, name ASC")
  213. private List<UnidirTop> unidirByIdAndName = new ArrayList<UnidirTop>();
  214. @OneToMany(cascade = CascadeType.ALL)
  215. @OrderBy("name DESC, id ASC")
  216. private List<UnidirTop> unidirByNameAndId = new ArrayList<UnidirTop>();
  217. public Long getId() {
  218. return id;
  219. }
  220. public List<UnidirTop> getUnidirByNameAndStr() {
  221. return unidirByNameAndStr;
  222. }
  223. public void setUnidirByNameAndStr(List<UnidirTop> unidirByNameAndStr) {
  224. this.unidirByNameAndStr = unidirByNameAndStr;
  225. }
  226. public List<UnidirTop> getUnidirByIdAndName() {
  227. return unidirByIdAndName;
  228. }
  229. public void setUnidirByIdAndName(List<UnidirTop> unidirByIdAndName) {
  230. this.unidirByIdAndName = unidirByIdAndName;
  231. }
  232. public List<UnidirTop> getUnidirByNameAndId() {
  233. return unidirByNameAndId;
  234. }
  235. public void setUnidirByNameAndId(List<UnidirTop> unidirByNameAndId) {
  236. this.unidirByNameAndId = unidirByNameAndId;
  237. }
  238. public String getVal() {
  239. return val;
  240. }
  241. public void setVal(String val) {
  242. this.val = val;
  243. }
  244. }
  245. @Entity
  246. public static class HasOneToManyChildAtMultipleLevelsJPA {
  247. @Id
  248. @GeneratedValue(strategy= GenerationType.IDENTITY)
  249. private Key id;
  250. @OneToMany(cascade = CascadeType.ALL)
  251. private List<UnidirTop> unidirChildren;
  252. @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
  253. @JoinColumn(name = "child_id")
  254. private HasOneToManyChildAtMultipleLevelsJPA child;
  255. public Key getId() {
  256. return id;
  257. }
  258. public List<UnidirTop> getUnidirChildren() {
  259. return unidirChildren;
  260. }
  261. public void setUnidirChildren(List<UnidirTop> unidirChildren) {
  262. this.unidirChildren = unidirChildren;
  263. }
  264. public HasOneToManyChildAtMultipleLevelsJPA getChild() {
  265. return child;
  266. }
  267. public void setChild(HasOneToManyChildAtMultipleLevelsJPA child) {
  268. this.child = child;
  269. }
  270. }
  271. @Entity
  272. public static class HasOneToManyWithUnsupportedInheritanceList {
  273. @Id
  274. @GeneratedValue(strategy= GenerationType.IDENTITY)
  275. private Key id;
  276. @OneToMany(cascade = CascadeType.ALL)
  277. private List<TablePerClass> children1 = new ArrayList<TablePerClass>();
  278. @OneToMany(cascade = CascadeType.ALL)
  279. private List<MappedSuperclassParent> children2 = new ArrayList<MappedSuperclassParent>();
  280. public Key getId() {
  281. return id;
  282. }
  283. public List<TablePerClass> getChildren1() {
  284. return children1;
  285. }
  286. public List<MappedSuperclassParent> getChildren2() {
  287. return children2;
  288. }
  289. }
  290. }