PageRenderTime 38ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://datanucleus-appengine.googlecode.com/
Java | 150 lines | 102 code | 29 blank | 19 comment | 0 complexity | 72a5a2900749d423159274396ee61f79 MD5 | raw file
Possible License(s): Apache-2.0
  1. /*
  2. * /**********************************************************************
  3. * Copyright (c) 2009 Google Inc.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. * **********************************************************************/
  17. package com.google.appengine.datanucleus.test;
  18. import java.util.List;
  19. import javax.jdo.annotations.Column;
  20. import javax.jdo.annotations.Embedded;
  21. import javax.jdo.annotations.EmbeddedOnly;
  22. import javax.jdo.annotations.IdGeneratorStrategy;
  23. import javax.jdo.annotations.IdentityType;
  24. import javax.jdo.annotations.PersistenceCapable;
  25. import javax.jdo.annotations.Persistent;
  26. import javax.jdo.annotations.PrimaryKey;
  27. /**
  28. * @author Max Ross <maxr@google.com>
  29. */
  30. @PersistenceCapable(identityType = IdentityType.APPLICATION)
  31. public class HasEmbeddedJDO {
  32. @PrimaryKey
  33. @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  34. private Long id;
  35. @Persistent
  36. @Embedded(members={
  37. @Persistent(name="id", columns=@Column(name="flightId"))
  38. })
  39. private Flight flight;
  40. @Persistent
  41. @Embedded(members={
  42. @Persistent(name="id", columns=@Column(name="ID")),
  43. @Persistent(name="origin", columns=@Column(name="ORIGIN")),
  44. @Persistent(name="dest", columns=@Column(name="DEST")),
  45. @Persistent(name="name", columns=@Column(name="NAME")),
  46. @Persistent(name="you", columns=@Column(name="YOU")),
  47. @Persistent(name="me", columns=@Column(name="ME")),
  48. @Persistent(name="flightNumber", columns=@Column(name="FLIGHTNUMBER"))
  49. })
  50. private Flight anotherFlight;
  51. @Persistent
  52. @Embedded
  53. private Embedded1 embedded1;
  54. public Long getId() {
  55. return id;
  56. }
  57. public Flight getFlight() {
  58. return flight;
  59. }
  60. public void setFlight(Flight flight) {
  61. this.flight = flight;
  62. }
  63. public Embedded1 getEmbedded1() {
  64. return embedded1;
  65. }
  66. public void setEmbedded1(Embedded1 embedded1) {
  67. this.embedded1 = embedded1;
  68. }
  69. public Flight getAnotherFlight() {
  70. return anotherFlight;
  71. }
  72. public void setAnotherFlight(Flight anotherFlight) {
  73. this.anotherFlight = anotherFlight;
  74. }
  75. @EmbeddedOnly
  76. @PersistenceCapable
  77. public static class Embedded1 {
  78. private String val1;
  79. @Persistent
  80. private List<String> multiVal1;
  81. @Persistent
  82. @Embedded
  83. private Embedded2 embedded2;
  84. public String getVal1() {
  85. return val1;
  86. }
  87. public void setVal1(String val1) {
  88. this.val1 = val1;
  89. }
  90. public Embedded2 getEmbedded2() {
  91. return embedded2;
  92. }
  93. public void setEmbedded2(Embedded2 embedded2) {
  94. this.embedded2 = embedded2;
  95. }
  96. public List<String> getMultiVal1() {
  97. return multiVal1;
  98. }
  99. public void setMultiVal1(List<String> multiVal1) {
  100. this.multiVal1 = multiVal1;
  101. }
  102. }
  103. @EmbeddedOnly
  104. @PersistenceCapable
  105. public static class Embedded2 {
  106. private String val2;
  107. private List<String> multiVal2;
  108. public String getVal2() {
  109. return val2;
  110. }
  111. public void setVal2(String val2) {
  112. this.val2 = val2;
  113. }
  114. public List<String> getMultiVal2() {
  115. return multiVal2;
  116. }
  117. public void setMultiVal2(List<String> multiVal2) {
  118. this.multiVal2 = multiVal2;
  119. }
  120. }
  121. }