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

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

http://datanucleus-appengine.googlecode.com/
Java | 92 lines | 56 code | 18 blank | 18 comment | 10 complexity | bb342c970f78e66d645a844b615c85b0 MD5 | raw file
Possible License(s): Apache-2.0
  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 com.google.appengine.datanucleus.Utils;
  16. import java.util.List;
  17. import javax.persistence.CascadeType;
  18. import javax.persistence.Entity;
  19. import javax.persistence.FetchType;
  20. import javax.persistence.GeneratedValue;
  21. import javax.persistence.GenerationType;
  22. import javax.persistence.Id;
  23. import javax.persistence.ManyToOne;
  24. import javax.persistence.OneToMany;
  25. /**
  26. * @author Max Ross <maxr@google.com>
  27. */
  28. @Entity
  29. public class BidirectionalChildListJPA implements BidirectionalChildJPA {
  30. @Id
  31. @GeneratedValue(strategy=GenerationType.IDENTITY)
  32. @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
  33. private String id;
  34. @ManyToOne(fetch = FetchType.LAZY)
  35. private HasOneToManyListJPA parent;
  36. @SuppressWarnings("unused")
  37. @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
  38. private List<BidirectionalGrandchildListJPA> bidirGrandchildren = Utils.newArrayList();
  39. private String childVal;
  40. public HasOneToManyListJPA getParent() {
  41. return parent;
  42. }
  43. public void setParent(HasOneToManyJPA parent) {
  44. this.parent = (HasOneToManyListJPA) parent;
  45. }
  46. public String getId() {
  47. return id;
  48. }
  49. public String getChildVal() {
  50. return childVal;
  51. }
  52. public void setChildVal(String childVal) {
  53. this.childVal = childVal;
  54. }
  55. public boolean equals(Object o) {
  56. if (this == o) {
  57. return true;
  58. }
  59. if (o == null || getClass() != o.getClass()) {
  60. return false;
  61. }
  62. BidirectionalChildListJPA that = (BidirectionalChildListJPA) o;
  63. if (id != null ? !id.equals(that.id) : that.id != null) {
  64. return false;
  65. }
  66. return true;
  67. }
  68. public int hashCode() {
  69. return (id != null ? id.hashCode() : 0);
  70. }
  71. }