01: /**
02: * Copyright (C) 2001-2005 France Telecom R&D
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * This library 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 GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */package org.objectweb.speedo.ejb.pobjects.basic;
18:
19: import junit.framework.Assert;
20:
21: import java.io.Serializable;
22:
23: import javax.persistence.Column;
24: import javax.persistence.Entity;
25: import javax.persistence.Id;
26: import javax.persistence.IdClass;
27: import javax.persistence.JoinColumn;
28: import javax.persistence.JoinColumns;
29: import javax.persistence.PrimaryKeyJoinColumn;
30: import javax.persistence.SecondaryTable;
31: import javax.persistence.Table;
32:
33: /**
34: * This class defines a mapping to two tables: a main table and one secondary
35: * table.
36: * @author P. Dechamboux
37: */
38: @Entity
39: @Table(name="EJB_MULTIJOINM")
40: @SecondaryTable(name="EJB_MULTIJOINS",pkJoinColumns={@PrimaryKeyJoinColumn(name="SID1",referencedColumnName="ID1"),@PrimaryKeyJoinColumn(name="SID2",referencedColumnName="ID2")})
41: @IdClass(CompPk.class)
42: public class MultiJoin implements Serializable {
43: @Id
44: @Column(name="ID1")
45: private int idp1;
46: @Id
47: @Column(name="ID2")
48: private int idp2;
49: @Column(name="MAIN")
50: private int int_main;
51: @Column(name="SECONDARY",table="EJB_MULTIJOINS")
52: private int int_secondary;
53:
54: public void assign(long longval) {
55: this .int_main = (int) longval;
56: this .int_secondary = (int) longval + 1;
57: }
58:
59: public void check(long longval) {
60: Assert.assertEquals("bad int_main value", int_main,
61: (int) longval);
62: Assert.assertEquals("bad int_secondary value", int_secondary,
63: (int) longval + 1);
64: }
65:
66: public int retrieve_int_field() {
67: return int_main;
68: }
69:
70: public void assign_int_field(int int_field) {
71: this .int_main = int_field;
72: this .int_secondary = int_field + 1;
73: }
74: }
|