]> review.fuel-infra Code Review - packages/trusty/mysql-wsrep-5.6.git/blob
a1212a887f06be3ba7257cd66a209c15b3e740d7
[packages/trusty/mysql-wsrep-5.6.git] /
1 /*
2    Copyright 2010 Sun Microsystems, Inc.
3    All rights reserved. Use is subject to license terms.
4
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.
8
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.
13
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
17 */
18
19 package com.mysql.clusterj.jpatest.model;
20
21 import java.io.Serializable;
22 import java.io.ObjectInputStream;
23 import java.io.ObjectOutputStream;
24 import java.io.IOException;
25
26 import javax.persistence.Basic;
27
28 /**
29  * An Entity test class that can be embedded in another.
30
31 drop table if exists t_basic;
32 create table t_basic (
33   id int not null,
34   name varchar(32), // embedded
35   age int,          // embedded
36   magic int not null,
37   primary key(id)) 
38   engine=ndbcluster;
39 create unique index idx_unique_hash_magic using hash on t_basic(magic);
40 create index idx_btree_age on t_basic(age);
41  */
42 @javax.persistence.Embeddable
43 public class Embedded implements Serializable {
44
45     private static final long serialVersionUID = -7939440091193693312L;
46
47     @Basic
48     private String name;
49
50     @Basic
51     private int age;
52
53     public Embedded() {
54     }
55
56     public int getAge() {
57         return age;
58     }
59
60     public void setAge(int age) {
61         this.age = age;
62     }
63
64     public String getName() {
65         return name;
66     }
67
68     public void setName(String name) {
69         this.name = name;
70     }
71
72     private void writeObject(ObjectOutputStream out) throws IOException {
73         out.defaultWriteObject();
74     }
75     
76     private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
77         in.defaultReadObject();
78     }
79     
80     @Override
81     public String toString() {
82         StringBuffer buffer = new StringBuffer();
83         buffer.append("Embedded name: ");
84         buffer.append(name);
85         buffer.append("; age: ");
86         buffer.append(age);
87         return buffer.toString();
88     }
89
90 }
91