PageRenderTime 12ms CodeModel.GetById 2ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

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

http://datanucleus-appengine.googlecode.com/
Java | 96 lines | 58 code | 20 blank | 18 comment | 10 complexity | c946b0b0623c6a9fa12d31f947a396c2 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 com.google.appengine.api.datastore.Key;
19import com.google.appengine.api.datastore.KeyFactory;
20
21import org.datanucleus.api.jpa.annotations.Extension;
22
23import javax.persistence.Basic;
24import javax.persistence.Entity;
25import javax.persistence.GeneratedValue;
26import javax.persistence.GenerationType;
27import javax.persistence.Id;
28
29/**
30 * @author Max Ross <maxr@google.com>
31 */
32@Entity
33public class HasKeyPkJPA {
34
35  @Extension(vendorName="datanucleus", key="gae.parent-pk", value="true")
36  @Basic
37  private Key ancestorId;
38
39  @Id
40  @GeneratedValue(strategy=GenerationType.IDENTITY)
41  private Key id;
42
43  String str;
44
45  public HasKeyPkJPA() {
46  }
47
48  public HasKeyPkJPA(String name) {
49    id = KeyFactory.createKey(getClass().getSimpleName(), name);
50  }
51
52  public Key getAncestorId() {
53    return ancestorId;
54  }
55
56  public Key getId() {
57    return id;
58  }
59
60  public void setAncestorId(Key ancestorId) {
61    this.ancestorId = ancestorId;
62  }
63
64  public void setId(Key id) {
65    this.id = id;
66  }
67
68  public String getStr() {
69    return str;
70  }
71
72  public void setStr(String str) {
73    this.str = str;
74  }
75
76  public boolean equals(Object o) {
77    if (this == o) {
78      return true;
79    }
80    if (o == null || getClass() != o.getClass()) {
81      return false;
82    }
83
84    HasKeyPkJPA that = (HasKeyPkJPA) o;
85
86    if (id != null ? !id.equals(that.id) : that.id != null) {
87      return false;
88    }
89
90    return true;
91  }
92
93  public int hashCode() {
94    return (id != null ? id.hashCode() : 0);
95  }
96}