2 Copyright 2010 Sun Microsystems, Inc.
3 All rights reserved. Use is subject to license terms.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; version 2 of the License.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 package com.mysql.clusterj.jpatest.model;
21 import java.io.Serializable;
22 import java.io.ObjectInputStream;
23 import java.io.ObjectOutputStream;
24 import java.io.IOException;
25 import java.util.Collection;
26 import java.util.HashSet;
29 * An Entity test class.
31 @javax.persistence.Entity
32 @javax.persistence.Table(name="a")
33 public class A implements Serializable {
34 // @Basic(fetch=EAGER) is the default mapping annotation
35 // for primitive types, wrappers, String...
37 // required for serialization
38 static private final long serialVersionUID = -3359921162347129079L;
49 private double cdouble;
51 private String cstring;
53 @javax.persistence.OneToMany(mappedBy="a")
54 private Collection<B0> b0s = new HashSet<B0>();
60 static public A create(int id) {
65 o.setCfloat((float)id);
66 o.setCdouble((double)id);
67 o.setCstring(String.valueOf(id));
75 public void setId(int id) {
79 public int getCint() {
83 public void setCint(int cint) {
87 public long getClong() {
91 public void setClong(long clong) {
95 public float getCfloat() {
99 public void setCfloat(float cfloat) {
100 this.cfloat = cfloat;
103 public double getCdouble() {
107 public void setCdouble(double cdouble) {
108 this.cdouble = cdouble;
111 public String getCstring() {
115 public void setCstring(String cstring) {
116 this.cstring = cstring;
119 public Collection<B0> getB0s() {
123 public void setB0s(Collection<B0> b0s) {
127 private void writeObject(ObjectOutputStream out) throws IOException {
128 out.defaultWriteObject();
131 private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
132 in.defaultReadObject();
135 static public class Oid implements Serializable {
143 public boolean equals(Object obj) {
144 if (obj == null || !this.getClass().equals(obj.getClass()))
147 return (this.id == o.id);
151 public int hashCode() {
157 public String toString() {
158 StringBuffer buffer = new StringBuffer();
159 buffer.append("A id: ");
161 buffer.append("; cint: ");
163 buffer.append("; clong: ");
164 buffer.append(clong);
165 buffer.append("; cfloat: ");
166 buffer.append(cfloat);
167 buffer.append("; cdouble: ");
168 buffer.append(cdouble);
169 buffer.append("; cstring: ");
170 buffer.append(cstring);
171 buffer.append("; collection<b0>(");
172 int size = b0s.size();
174 buffer.append("): [");
175 String separator = "";
177 buffer.append(separator);
178 buffer.append (b.getId());
182 return buffer.toString();