PageRenderTime 61ms CodeModel.GetById 48ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://datanucleus-appengine.googlecode.com/
Java | 65 lines | 36 code | 11 blank | 18 comment | 2 complexity | 5f9f7155824b92ad9c5e237d4d361acb MD5 | raw file
 1/**********************************************************************
 2Copyright (c) 2011 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 java.util.HashSet;
19import java.util.Set;
20
21import javax.jdo.annotations.IdGeneratorStrategy;
22import javax.jdo.annotations.PersistenceCapable;
23import javax.jdo.annotations.Persistent;
24import javax.jdo.annotations.PrimaryKey;
25
26import com.google.appengine.datanucleus.annotations.Unowned;
27
28/**
29 * "Owner" of a 1-N bidirectional relation in JDO, using unowned relations.
30 */
31@PersistenceCapable(detachable="true")
32public class UnownedJDOOneToManyBiSideA {
33  @PrimaryKey
34  @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
35  Long id;
36
37  @Persistent(mappedBy="related")
38  @Unowned
39  Set<UnownedJDOOneToManyBiSideB> others;
40
41  String name;
42
43  public Long getId() {
44    return id;
45  }
46
47  public void setName(String name) {
48    this.name = name;
49  }
50
51  public String getName() {
52    return name;
53  }
54
55  public void addOther(UnownedJDOOneToManyBiSideB other) {
56    if (this.others == null) {
57      this.others = new HashSet<UnownedJDOOneToManyBiSideB>();
58    }
59    this.others.add(other);
60  }
61
62  public Set<UnownedJDOOneToManyBiSideB> getOthers() {
63    return others;
64  }
65}