PageRenderTime 56ms CodeModel.GetById 21ms app.highlight 29ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://datanucleus-appengine.googlecode.com/
Java | 189 lines | 131 code | 43 blank | 15 comment | 0 complexity | 18c0f821e66c2fa017a5574c6edd2a14 MD5 | raw file
  1/**********************************************************************
  2 Copyright (c) 2011 Google Inc.
  3
  4 Licensed under the Apache License, Version 2.0 (the "License");
  5 you may not use this file except in compliance with the License.
  6 You may obtain a copy of the License at
  7
  8 http://www.apache.org/licenses/LICENSE-2.0
  9
 10 Unless required by applicable law or agreed to in writing, software
 11 distributed under the License is distributed on an "AS IS" BASIS,
 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13 See the License for the specific language governing permissions and
 14 limitations under the License.
 15 **********************************************************************/
 16package com.google.appengine.datanucleus.test;
 17
 18import com.google.appengine.api.datastore.Key;
 19import com.google.appengine.datanucleus.test.BidirectionalSingleTableChildJPA.BidirTop;
 20import com.google.appengine.datanucleus.test.BidirectionalSingleTableChildJPA.BidirTopLongPk;
 21import com.google.appengine.datanucleus.test.BidirectionalSingleTableChildJPA.BidirTopUnencodedStringPk;
 22import com.google.appengine.datanucleus.test.BidirectionalSingleTableChildSetJPA.BidirTopLongPkSet;
 23import com.google.appengine.datanucleus.test.BidirectionalSingleTableChildSetJPA.BidirTopSet;
 24import com.google.appengine.datanucleus.test.BidirectionalSingleTableChildSetJPA.BidirTopUnencodedStringPkSet;
 25import com.google.appengine.datanucleus.test.HasPolymorphicRelationsJPA.HasOneToManyJPA;
 26import com.google.appengine.datanucleus.test.HasPolymorphicRelationsJPA.HasOneToManyKeyPkJPA;
 27import com.google.appengine.datanucleus.test.HasPolymorphicRelationsJPA.HasOneToManyLongPkJPA;
 28import com.google.appengine.datanucleus.test.HasPolymorphicRelationsJPA.HasOneToManyUnencodedStringPkJPA;
 29import com.google.appengine.datanucleus.test.UnidirectionalSingeTableChildJPA.UnidirTop;
 30
 31import org.datanucleus.api.jpa.annotations.Extension;
 32
 33import java.util.Collection;
 34import java.util.HashSet;
 35import java.util.Set;
 36
 37import javax.persistence.CascadeType;
 38import javax.persistence.Entity;
 39import javax.persistence.GeneratedValue;
 40import javax.persistence.GenerationType;
 41import javax.persistence.Id;
 42import javax.persistence.OneToMany;
 43
 44public class HasPolymorphicRelationsSetJPA {
 45  @Entity
 46  public static class HasOneToManySetJPA implements HasOneToManyJPA {
 47
 48    @Id
 49    @GeneratedValue(strategy = GenerationType.IDENTITY)
 50    @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
 51    private String id;
 52
 53    private String val;
 54
 55    @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
 56    private Set<BidirTopSet> bidirChildren = new HashSet<BidirTopSet>();
 57
 58    @OneToMany(cascade = CascadeType.ALL)
 59    private Set<UnidirTop> unidirChildren = new HashSet<UnidirTop>();
 60
 61    @OneToMany(cascade = CascadeType.ALL)
 62    private Set<HasKeyPkJPA> hasKeyPks = new HashSet<HasKeyPkJPA>();
 63
 64    public String getId() {
 65      return id;
 66    }
 67
 68    public Set<BidirTop> getBidirChildren() {
 69      return (Set) bidirChildren;
 70    }
 71
 72    public void nullBidirChildren() {
 73      this.bidirChildren = null;
 74    }
 75
 76    public Set<UnidirTop> getUnidirChildren() {
 77      return unidirChildren;
 78    }
 79
 80    public void nullUnidirChildren() {
 81      this.unidirChildren = null;
 82    }
 83
 84    public Set<HasKeyPkJPA> getHasKeyPks() {
 85      return hasKeyPks;
 86    }
 87
 88    public void nullHasKeyPks() {
 89      this.hasKeyPks = null;
 90    }
 91
 92    public String getVal() {
 93      return val;
 94    }
 95
 96    public void setVal(String val) {
 97      this.val = val;
 98    }
 99  }
100  
101  @Entity
102  public static class HasOneToManyKeyPkSetJPA implements HasOneToManyKeyPkJPA {
103
104    @Id
105    @GeneratedValue(strategy=GenerationType.IDENTITY)
106    private Key id;
107
108    @OneToMany(cascade = CascadeType.ALL)
109    private Set<UnidirTop> unidirChildren = new HashSet<UnidirTop>();
110
111    public Key getId() {
112      return id;
113    }
114
115    public Set<UnidirTop> getUnidirChildren() {
116      return unidirChildren;
117    }
118
119    public void nullBooks() {
120      this.unidirChildren = null;
121    }
122
123  }
124  
125  @Entity
126  public static class HasOneToManyLongPkSetJPA implements HasOneToManyLongPkJPA {
127
128    @Id
129    @GeneratedValue(strategy=GenerationType.IDENTITY)
130    private Long id;
131
132    @OneToMany(cascade = CascadeType.ALL)
133    private Set<UnidirTop> unidirChildren = new HashSet<UnidirTop>();
134
135    @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
136    private Set<BidirTopLongPkSet> bidirChildren =
137        new HashSet<BidirTopLongPkSet>();
138
139    public Long getId() {
140      return id;
141    }
142
143    public Set<UnidirTop> getUnidirChildren() {
144      return unidirChildren;
145    }
146
147    public void unidirChildren() {
148      this.unidirChildren = null;
149    }
150
151    public Collection<BidirTopLongPk> getBidirChildren() {
152      return (Set) bidirChildren;
153    }
154  }
155  
156  @Entity
157  public static class HasOneToManyUnencodedStringPkSetJPA implements HasOneToManyUnencodedStringPkJPA {
158
159    @Id
160    private String id;
161
162    @OneToMany(cascade = CascadeType.ALL)
163    private Set<UnidirTop> books = new HashSet<UnidirTop>();
164
165    @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
166    private Set<BidirTopUnencodedStringPkSet> bidirChildren =
167        new HashSet<BidirTopUnencodedStringPkSet>();
168
169    public String getId() {
170      return id;
171    }
172
173    public void setId(String id) {
174      this.id = id;
175    }
176
177    public Set<UnidirTop> getUnidirChildren() {
178      return books;
179    }
180
181    public void nullBooks() {
182      this.books = null;
183    }
184
185    public Collection<BidirTopUnencodedStringPk> getBidirChildren() {
186      return (Set) bidirChildren;
187    }
188  }
189}