]> review.fuel-infra Code Review - packages/trusty/mysql-wsrep-5.6.git/blob
c471b28edc0e59423a5e698da7c2416538662818
[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.IOException;
22 import java.io.ObjectInputStream;
23 import java.io.ObjectOutputStream;
24 import java.io.Serializable;
25
26 import javax.persistence.Basic;
27
28 /**
29  * An Entity test class that has an embedded class.
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.Entity
43 @javax.persistence.Table(name="t_basic")
44 public class Embedding implements IdBase, Serializable {
45
46     private static final long serialVersionUID = -5449615148226881972L;
47
48     @javax.persistence.Id
49     private int id;
50
51     @Basic
52     private int magic;
53
54     // defaults to @Embedded
55     private Embedded embedded;
56
57     public Embedding() {
58     }
59
60     public int getId() {
61         return id;
62     }
63     
64     public void setId(int id) {
65         this.id = id;
66     }
67     
68     public int getMagic() {
69         return magic;
70     }
71
72     public void setMagic(int magic) {
73         this.magic = magic;
74     }
75
76     public Embedded getEmbedded() {
77         return embedded;
78     }
79
80     public void setEmbedded(Embedded embedded) {
81         this.embedded = embedded;
82     }
83
84     private void writeObject(ObjectOutputStream out) throws IOException {
85         out.defaultWriteObject();
86     }
87     
88     private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
89         in.defaultReadObject();
90     }
91     
92     @Override
93     public String toString() {
94         StringBuffer buffer = new StringBuffer();
95         buffer.append("Embedding id: ");
96         buffer.append(id);
97         buffer.append("; magic: "); 
98         buffer.append(magic);
99         buffer.append("; embedded: ");
100         buffer.append(embedded.toString());
101         return buffer.toString();
102     }
103
104 }
105