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