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

http://datanucleus-appengine.googlecode.com/ · Java · 113 lines · 72 code · 23 blank · 18 comment · 0 complexity · 4d420a519f9be9ae67fbf7d8b8900b82 MD5 · raw file

  1. /**********************************************************************
  2. Copyright (c) 2009 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 org.datanucleus.api.jpa.annotations.Extension;
  15. import javax.persistence.CascadeType;
  16. import javax.persistence.Entity;
  17. import javax.persistence.FetchType;
  18. import javax.persistence.GeneratedValue;
  19. import javax.persistence.GenerationType;
  20. import javax.persistence.Id;
  21. import javax.persistence.JoinColumn;
  22. import javax.persistence.OneToOne;
  23. /**
  24. * @author Max Ross <maxr@google.com>
  25. */
  26. @Entity
  27. public class HasOneToOneJPA {
  28. @Id
  29. @GeneratedValue(strategy=GenerationType.IDENTITY)
  30. @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
  31. private String id;
  32. @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
  33. @JoinColumn(name = "book_id")
  34. private Book book;
  35. @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
  36. @JoinColumn(name = "haskeypk_id")
  37. private HasKeyPkJPA hasKeyPK;
  38. @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
  39. @JoinColumn(name = "hasparent_id")
  40. private HasOneToOneParentJPA hasParent;
  41. @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
  42. @JoinColumn(name = "hasparentkeypk_id")
  43. private HasOneToOneParentKeyPkJPA hasParentKeyPK;
  44. @OneToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH}, fetch = FetchType.LAZY)
  45. @JoinColumn(name = "notdependent_id")
  46. private HasEncodedStringPkJPA notDependent;
  47. private String str;
  48. public String getId() {
  49. return id;
  50. }
  51. public Book getBook() {
  52. return book;
  53. }
  54. public void setBook(Book book) {
  55. this.book = book;
  56. }
  57. public HasKeyPkJPA getHasKeyPK() {
  58. return hasKeyPK;
  59. }
  60. public void setHasKeyPK(HasKeyPkJPA hasKeyPK) {
  61. this.hasKeyPK = hasKeyPK;
  62. }
  63. public HasOneToOneParentJPA getHasParent() {
  64. return hasParent;
  65. }
  66. public void setHasParent(HasOneToOneParentJPA hasParent) {
  67. this.hasParent = hasParent;
  68. }
  69. public HasOneToOneParentKeyPkJPA getHasParentKeyPK() {
  70. return hasParentKeyPK;
  71. }
  72. public void setHasParentKeyPK(HasOneToOneParentKeyPkJPA hasParentKeyPK) {
  73. this.hasParentKeyPK = hasParentKeyPK;
  74. }
  75. public HasEncodedStringPkJPA getNotDependent() {
  76. return notDependent;
  77. }
  78. public void setNotDependent(HasEncodedStringPkJPA notDependent) {
  79. this.notDependent = notDependent;
  80. }
  81. public String getStr() {
  82. return str;
  83. }
  84. public void setStr(String str) {
  85. this.str = str;
  86. }
  87. }