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.IOException;
22 import java.io.ObjectInputStream;
23 import java.io.ObjectOutputStream;
24 import java.io.Serializable;
26 import javax.persistence.Basic;
29 * An Entity test class that has an embedded class.
31 drop table if exists t_basic;
32 create table t_basic (
34 name varchar(32), // embedded
39 create unique index idx_unique_hash_magic using hash on t_basic(magic);
40 create index idx_btree_age on t_basic(age);
42 @javax.persistence.Entity
43 @javax.persistence.Table(name="t_basic")
44 public class Embedding implements IdBase, Serializable {
46 private static final long serialVersionUID = -5449615148226881972L;
54 // defaults to @Embedded
55 private Embedded embedded;
64 public void setId(int id) {
68 public int getMagic() {
72 public void setMagic(int magic) {
76 public Embedded getEmbedded() {
80 public void setEmbedded(Embedded embedded) {
81 this.embedded = embedded;
84 private void writeObject(ObjectOutputStream out) throws IOException {
85 out.defaultWriteObject();
88 private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
89 in.defaultReadObject();
93 public String toString() {
94 StringBuffer buffer = new StringBuffer();
95 buffer.append("Embedding id: ");
97 buffer.append("; magic: ");
99 buffer.append("; embedded: ");
100 buffer.append(embedded.toString());
101 return buffer.toString();