PageRenderTime 46ms CodeModel.GetById 39ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://datanucleus-appengine.googlecode.com/
Java | 137 lines | 91 code | 28 blank | 18 comment | 0 complexity | 3d29c20442619373d88d8a9e0f507cbf MD5 | raw file
  1/**********************************************************************
  2 Copyright (c) 2009 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 javax.persistence.Entity;
 19import javax.persistence.GeneratedValue;
 20import javax.persistence.GenerationType;
 21import javax.persistence.Id;
 22import javax.persistence.SequenceGenerator;
 23
 24/**
 25 * @author Max Ross <maxr@google.com>
 26 */
 27public final class SequenceExamplesJPA {
 28
 29  private SequenceExamplesJPA() {}
 30  
 31  @Entity
 32  public static class HasSequence {
 33
 34    @Id
 35    @GeneratedValue(strategy = GenerationType.SEQUENCE)
 36    private Long id;
 37
 38    private String val;
 39
 40    public Long getId() {
 41      return id;
 42    }
 43
 44    public void setId(Long id) {
 45      this.id = id;
 46    }
 47
 48    public String getVal() {
 49      return val;
 50    }
 51
 52    public void setVal(String val) {
 53      this.val = val;
 54    }
 55  }
 56
 57  @Entity
 58  public static class HasSequenceWithSequenceGenerator {
 59    @Id
 60    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "jpa1")
 61    @SequenceGenerator(name = "jpa1", sequenceName = "jpathat", allocationSize = 12)
 62    private Long id;
 63
 64    private String val;
 65
 66    public Long getId() {
 67      return id;
 68    }
 69
 70    public void setId(Long id) {
 71      this.id = id;
 72    }
 73
 74    public String getVal() {
 75      return val;
 76    }
 77
 78    public void setVal(String val) {
 79      this.val = val;
 80    }
 81  }
 82
 83  @Entity
 84  public static class HasSequenceWithNoSequenceName {
 85    @Id
 86    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "jpa2")
 87    @SequenceGenerator(name = "jpa2", allocationSize = 12)
 88    private Long id;
 89
 90    public Long getId() {
 91      return id;
 92    }
 93
 94    public void setId(Long id) {
 95      this.id = id;
 96    }
 97  }
 98
 99  @Entity
100  public static class HasSequenceWithUnencodedStringPk {
101    @Id
102    @GeneratedValue(strategy = GenerationType.SEQUENCE)
103    private String id;
104
105    public String getId() {
106      return id;
107    }
108  }
109
110  @Entity
111  public static class HasSequenceOnNonPkFields {
112    @Id
113    private String id;
114
115    @GeneratedValue(strategy = GenerationType.SEQUENCE)
116    private long val;
117
118    @GeneratedValue(strategy = GenerationType.SEQUENCE)
119    private long val2;
120
121    public String getId() {
122      return id;
123    }
124
125    public void setId(String id) {
126      this.id = id;
127    }
128
129    public long getVal() {
130      return val;
131    }
132
133    public long getVal2() {
134      return val2;
135    }
136  }
137}