MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
B0.java
1 /*
2  Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 package com.mysql.clusterj.jpatest.model;
19 
20 import java.io.Serializable;
21 import java.io.ObjectInputStream;
22 import java.io.ObjectOutputStream;
23 import java.io.IOException;
24 
28 @javax.persistence.Entity
29 @javax.persistence.Table(name="b0")
30 public class B0 implements Serializable {
31  // @Basic(fetch=EAGER) is the default mapping annotation
32  // for primitive types, wrappers, String...
33 
34  // for serializable
35  static private final long serialVersionUID = 4644052765183330073L;
36 
37  @javax.persistence.Id
38  private int id;
39 
40  private int cint;
41 
42  private long clong;
43 
44  private float cfloat;
45 
46  private double cdouble;
47 
48  private String cstring;
49 
50  private byte[] bytes;
51 
52  @javax.persistence.ManyToOne
53  @javax.persistence.Column(name="a_id")
54  @org.apache.openjpa.persistence.jdbc.Index(name="FK_a_id")
55  private A a;
56 
57  public B0() {
58  }
59 
60  static public B0 create(int id) {
61  B0 o = new B0();
62  o.setId(id);
63  o.setCint((int)id);
64  o.setClong((long)id);
65  o.setCfloat((float)id);
66  o.setCdouble((double)id);
67  o.setCstring(String.valueOf(id));
68  return o;
69  }
70 
71  public int getId() {
72  return id;
73  }
74 
75  public void setId(int id) {
76  this.id = id;
77  }
78 
79  public int getCint() {
80  return cint;
81  }
82 
83  public void setCint(int cint) {
84  this.cint = cint;
85  }
86 
87  public long getClong() {
88  return clong;
89  }
90 
91  public void setClong(long clong) {
92  this.clong = clong;
93  }
94 
95  public float getCfloat() {
96  return cfloat;
97  }
98 
99  public void setBytes(byte[] value) {
100  this.bytes = value;
101  }
102 
103  public byte[] getBytes() {
104  return bytes;
105  }
106 
107  public void setCfloat(float cfloat) {
108  this.cfloat = cfloat;
109  }
110 
111  public double getCdouble() {
112  return cdouble;
113  }
114 
115  public void setCdouble(double cdouble) {
116  this.cdouble = cdouble;
117  }
118 
119  public String getCstring() {
120  return cstring;
121  }
122 
123  public void setCstring(String cstring) {
124  this.cstring = cstring;
125  }
126 
127  public A getA() {
128  return a;
129  }
130 
131  public void setA(A a) {
132  this.a = a;
133  }
134 
135  private void writeObject(ObjectOutputStream out) throws IOException {
136  out.defaultWriteObject();
137  }
138 
139  private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
140  in.defaultReadObject();
141  }
142 
143  static public class Oid implements Serializable {
144 
145  public int id;
146 
147  public Oid() {
148  }
149 
150  @Override
151  public boolean equals(Object obj) {
152  if (obj == null || !this.getClass().equals(obj.getClass()))
153  return false;
154  Oid o = (Oid)obj;
155  return (this.id == o.id);
156  }
157 
158  @Override
159  public int hashCode() {
160  return id;
161  }
162  }
163 
164  @Override
165  public String toString() {
166  StringBuffer buffer = new StringBuffer();
167  buffer.append("B0 id: ");
168  buffer.append(id);
169  buffer.append("; cint: ");
170  buffer.append(cint);
171  buffer.append("; clong: ");
172  buffer.append(clong);
173  buffer.append("; cfloat: ");
174  buffer.append(cfloat);
175  buffer.append("; cdouble: ");
176  buffer.append(cdouble);
177  buffer.append("; cstring: ");
178  buffer.append(cstring);
179  buffer.append("; a: ");
180  buffer.append(a);
181  return buffer.toString();
182  }
183 
184 }