PageRenderTime 20ms CodeModel.GetById 1ms app.highlight 14ms RepoModel.GetById 1ms 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
 1/**********************************************************************
 2Copyright (c) 2009 Google Inc.
 3
 4Licensed under the Apache License, Version 2.0 (the "License");
 5you may not use this file except in compliance with the License.
 6You may obtain a copy of the License at
 7
 8http://www.apache.org/licenses/LICENSE-2.0
 9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15**********************************************************************/
16package com.google.appengine.datanucleus.test;
17
18import org.datanucleus.api.jpa.annotations.Extension;
19
20import com.google.appengine.datanucleus.Utils;
21
22import java.util.List;
23
24import javax.persistence.CascadeType;
25import javax.persistence.Entity;
26import javax.persistence.FetchType;
27import javax.persistence.GeneratedValue;
28import javax.persistence.GenerationType;
29import javax.persistence.Id;
30import javax.persistence.ManyToOne;
31import javax.persistence.OneToMany;
32
33/**
34 * @author Max Ross <maxr@google.com>
35 */
36@Entity
37public class BidirectionalChildListJPA implements BidirectionalChildJPA {
38  @Id
39  @GeneratedValue(strategy=GenerationType.IDENTITY)
40  @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
41  private String id;
42
43  @ManyToOne(fetch = FetchType.LAZY)
44  private HasOneToManyListJPA parent;
45
46  @SuppressWarnings("unused")
47  @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
48  private List<BidirectionalGrandchildListJPA> bidirGrandchildren = Utils.newArrayList();
49
50  private String childVal;
51
52  public HasOneToManyListJPA getParent() {
53    return parent;
54  }
55
56  public void setParent(HasOneToManyJPA parent) {
57    this.parent = (HasOneToManyListJPA) parent;
58  }
59
60  public String getId() {
61    return id;
62  }
63
64  public String getChildVal() {
65    return childVal;
66  }
67
68  public void setChildVal(String childVal) {
69    this.childVal = childVal;
70  }
71
72  public boolean equals(Object o) {
73    if (this == o) {
74      return true;
75    }
76    if (o == null || getClass() != o.getClass()) {
77      return false;
78    }
79
80    BidirectionalChildListJPA that = (BidirectionalChildListJPA) o;
81
82    if (id != null ? !id.equals(that.id) : that.id != null) {
83      return false;
84    }
85
86    return true;
87  }
88
89  public int hashCode() {
90    return (id != null ? id.hashCode() : 0);
91  }
92}