PageRenderTime 33ms CodeModel.GetById 15ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://datanucleus-appengine.googlecode.com/
Java | 91 lines | 55 code | 18 blank | 18 comment | 10 complexity | a3397c97e666494c327a534998fc3732 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.TestUtils;
21
22import javax.persistence.Entity;
23import javax.persistence.FetchType;
24import javax.persistence.GeneratedValue;
25import javax.persistence.GenerationType;
26import javax.persistence.Id;
27import javax.persistence.ManyToOne;
28
29/**
30 * @author Max Ross <maxr@google.com>
31 */
32@Entity
33public class BidirectionalChildSetJPA implements BidirectionalChildJPA {
34  @Id
35  @GeneratedValue(strategy=GenerationType.IDENTITY)
36  @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
37  private String id;
38
39  @ManyToOne(fetch = FetchType.LAZY)
40  private HasOneToManySetJPA parent;
41
42  private String childVal;
43
44  public BidirectionalChildSetJPA() {
45  }
46
47  public BidirectionalChildSetJPA(String id) {
48    this.id = TestUtils.createKeyString(this, id);
49  }
50
51  public HasOneToManySetJPA getParent() {
52    return parent;
53  }
54
55  public void setParent(HasOneToManyJPA parent) {
56    this.parent = (HasOneToManySetJPA) parent;
57  }
58
59  public String getId() {
60    return id;
61  }
62
63  public String getChildVal() {
64    return childVal;
65  }
66
67  public void setChildVal(String childVal) {
68    this.childVal = childVal;
69  }
70
71  public boolean equals(Object o) {
72    if (this == o) {
73      return true;
74    }
75    if (o == null || getClass() != o.getClass()) {
76      return false;
77    }
78
79    BidirectionalChildSetJPA that = (BidirectionalChildSetJPA) o;
80
81    if (id != null ? !id.equals(that.id) : that.id != null) {
82      return false;
83    }
84
85    return true;
86  }
87
88  public int hashCode() {
89    return (id != null ? id.hashCode() : 0);
90  }
91}