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 javax.persistence.JoinColumn;
23 import javax.persistence.JoinColumns;
24 import javax.persistence.ManyToOne;
28 create table longlongstringfk (
29 longpk1 bigint not null,
30 longpk2 bigint not null,
31 stringpk varchar(10) not null,
32 longfk1 bigint not null,
33 longfk2 bigint not null,
34 stringfk varchar(10) not null,
35 stringvalue varchar(10),
36 KEY FK_longfk1longfk2stringfk (longfk1, longfk2, stringfk),
37 CONSTRAINT PK_longlongstringfk PRIMARY KEY (longpk1, longpk2, stringpk)
39 ) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
41 @javax.persistence.Entity
42 @javax.persistence.Table(name="longlongstringfk")
43 @javax.persistence.IdClass(value=LongLongStringOid.class)
44 public class LongLongStringFKManyOne extends LongLongStringConstants implements Serializable {
47 @javax.persistence.Column(name="longpk1")
51 @javax.persistence.Column(name="longpk2")
55 @javax.persistence.Column(name="stringpk")
56 private String stringpk;
60 @JoinColumn(name="longfk1", referencedColumnName="longpk1"),
61 @JoinColumn(name="longfk2", referencedColumnName="longpk2"),
62 @JoinColumn(name="stringfk", referencedColumnName="stringpk")
64 @org.apache.openjpa.persistence.jdbc.Index(name="FK_longfk1longfk2stringfk")
65 private LongLongStringPKOneMany longLongStringPKOneMany;
67 @javax.persistence.Column(name="stringvalue")
68 private String stringvalue;
70 public LongLongStringFKManyOne() {
73 public long getLongpk1() {
77 public void setLongpk1(long value) {
81 public long getLongpk2() {
85 public void setLongpk2(long value) {
89 public String getStringpk() {
93 public void setStringpk(String value) {
97 public LongLongStringPKOneMany getLongLongStringPKOneMany() {
98 return longLongStringPKOneMany;
101 public void setLongLongStringPKRelationship(LongLongStringPKOneMany value) {
102 longLongStringPKOneMany = value;
105 static public LongLongStringFKManyOne create(int id) {
106 LongLongStringFKManyOne o = new LongLongStringFKManyOne();
107 o.longpk1 = getPK1(id);
108 o.longpk2 = getPK2(id);
109 o.stringpk = getPK3(id);
110 o.stringvalue = getValue(id);
114 static public LongLongStringOid createOid(int id) {
115 LongLongStringOid oid = new LongLongStringOid(id);
120 public String toString() {
121 StringBuffer result = new StringBuffer();
122 result.append("LongLongStringFK[");
123 result.append(longpk1);
125 result.append(longpk2);
126 result.append(",\"");
127 result.append(stringpk);
128 result.append("\"]: ");
129 result.append(stringvalue);
130 result.append(" -> (");
131 result.append((longLongStringPKOneMany==null)?"null":longLongStringPKOneMany.toString());
133 return result.toString();