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;
26 import javax.persistence.Basic;
29 * An Entity test class that can be embedded in another.
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.Embeddable
43 public class Embedded implements Serializable {
45 private static final long serialVersionUID = -7939440091193693312L;
60 public void setAge(int age) {
64 public String getName() {
68 public void setName(String name) {
72 private void writeObject(ObjectOutputStream out) throws IOException {
73 out.defaultWriteObject();
76 private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
77 in.defaultReadObject();
81 public String toString() {
82 StringBuffer buffer = new StringBuffer();
83 buffer.append("Embedded name: ");
85 buffer.append("; age: ");
87 return buffer.toString();