PageRenderTime 38ms CodeModel.GetById 29ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://datanucleus-appengine.googlecode.com/
Java | 74 lines | 43 code | 16 blank | 15 comment | 0 complexity | 8f9e7fb0f30aefddcff7286e2f33ca11 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 java.util.HashSet;
21import java.util.Set;
22
23import javax.persistence.CascadeType;
24import javax.persistence.Entity;
25import javax.persistence.GeneratedValue;
26import javax.persistence.GenerationType;
27import javax.persistence.Id;
28import javax.persistence.OneToMany;
29
30public class HasRecursiveParentJPA {
31
32  public HasRecursiveParentJPA() {
33  }
34
35  @Entity
36  public static class HasRecursiveParent {
37    @Id
38    @GeneratedValue(strategy = GenerationType.IDENTITY)
39    @Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")
40    private String id;
41
42    private String name;
43
44    private HasRecursiveParent parent;
45
46    @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
47    private Set<HasRecursiveParent> children = new HashSet<HasRecursiveParent>();
48
49    public String getId() {
50      return id;
51    }
52
53    public String getName() {
54      return name;
55    }
56
57    public void setName(String name) {
58      this.name = name;
59    }
60
61    public HasRecursiveParent getParent() {
62      return parent;
63    }
64
65    public void setParent(HasRecursiveParent parent) {
66      this.parent = parent;
67    }
68
69    public Set<HasRecursiveParent> getChildren() {
70      return children;
71    }
72  }
73  
74}