PageRenderTime 59ms CodeModel.GetById 32ms app.highlight 21ms RepoModel.GetById 1ms app.codeStats 1ms

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

http://datanucleus-appengine.googlecode.com/
Java | 150 lines | 102 code | 29 blank | 19 comment | 0 complexity | 72a5a2900749d423159274396ee61f79 MD5 | raw file
  1/*
  2 * /**********************************************************************
  3 * Copyright (c) 2009 Google Inc.
  4 *
  5 * Licensed under the Apache License, Version 2.0 (the "License");
  6 * you may not use this file except in compliance with the License.
  7 * You may obtain a copy of the License at
  8 *
  9 * http://www.apache.org/licenses/LICENSE-2.0
 10 *
 11 * Unless required by applicable law or agreed to in writing, software
 12 * distributed under the License is distributed on an "AS IS" BASIS,
 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14 * See the License for the specific language governing permissions and
 15 * limitations under the License.
 16 * **********************************************************************/
 17
 18package com.google.appengine.datanucleus.test;
 19
 20import java.util.List;
 21
 22import javax.jdo.annotations.Column;
 23import javax.jdo.annotations.Embedded;
 24import javax.jdo.annotations.EmbeddedOnly;
 25import javax.jdo.annotations.IdGeneratorStrategy;
 26import javax.jdo.annotations.IdentityType;
 27import javax.jdo.annotations.PersistenceCapable;
 28import javax.jdo.annotations.Persistent;
 29import javax.jdo.annotations.PrimaryKey;
 30
 31/**
 32 * @author Max Ross <maxr@google.com>
 33 */
 34@PersistenceCapable(identityType = IdentityType.APPLICATION)
 35public class HasEmbeddedJDO {
 36
 37  @PrimaryKey
 38  @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
 39  private Long id;
 40
 41  @Persistent
 42  @Embedded(members={
 43              @Persistent(name="id", columns=@Column(name="flightId"))
 44              })
 45  private Flight flight;
 46
 47  @Persistent
 48  @Embedded(members={
 49              @Persistent(name="id", columns=@Column(name="ID")),
 50              @Persistent(name="origin", columns=@Column(name="ORIGIN")),
 51              @Persistent(name="dest", columns=@Column(name="DEST")),
 52              @Persistent(name="name", columns=@Column(name="NAME")),
 53              @Persistent(name="you", columns=@Column(name="YOU")),
 54              @Persistent(name="me", columns=@Column(name="ME")),
 55              @Persistent(name="flightNumber", columns=@Column(name="FLIGHTNUMBER"))
 56              })
 57  private Flight anotherFlight;
 58
 59  @Persistent
 60  @Embedded
 61  private Embedded1 embedded1;
 62
 63  public Long getId() {
 64    return id;
 65  }
 66
 67  public Flight getFlight() {
 68    return flight;
 69  }
 70
 71  public void setFlight(Flight flight) {
 72    this.flight = flight;
 73  }
 74
 75  public Embedded1 getEmbedded1() {
 76    return embedded1;
 77  }
 78
 79  public void setEmbedded1(Embedded1 embedded1) {
 80    this.embedded1 = embedded1;
 81  }
 82
 83  public Flight getAnotherFlight() {
 84    return anotherFlight;
 85  }
 86
 87  public void setAnotherFlight(Flight anotherFlight) {
 88    this.anotherFlight = anotherFlight;
 89  }
 90
 91  @EmbeddedOnly
 92  @PersistenceCapable
 93  public static class Embedded1 {
 94    private String val1;
 95
 96    @Persistent
 97    private List<String> multiVal1;
 98    
 99    @Persistent
100    @Embedded
101    private Embedded2 embedded2;
102
103    public String getVal1() {
104      return val1;
105    }
106
107    public void setVal1(String val1) {
108      this.val1 = val1;
109    }
110
111    public Embedded2 getEmbedded2() {
112      return embedded2;
113    }
114
115    public void setEmbedded2(Embedded2 embedded2) {
116      this.embedded2 = embedded2;
117    }
118
119    public List<String> getMultiVal1() {
120      return multiVal1;
121    }
122
123    public void setMultiVal1(List<String> multiVal1) {
124      this.multiVal1 = multiVal1;
125    }
126  }
127
128  @EmbeddedOnly
129  @PersistenceCapable
130  public static class Embedded2 {
131    private String val2;
132    private List<String> multiVal2;
133
134    public String getVal2() {
135      return val2;
136    }
137
138    public void setVal2(String val2) {
139      this.val2 = val2;
140    }
141
142    public List<String> getMultiVal2() {
143      return multiVal2;
144    }
145
146    public void setMultiVal2(List<String> multiVal2) {
147      this.multiVal2 = multiVal2;
148    }
149  }
150}