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