blob: b20443506a57c4809219e64658059039d03192dc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
/*******************************************************************************
* Copyright (c) 2006, 2008 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
*
* Contributors:
* Oracle - initial API and implementation
******************************************************************************/
package org.eclipse.jpt.gen.internal;
import org.eclipse.jpt.db.ForeignKey;
import org.eclipse.jpt.utility.internal.StringTools;
/**
* This object is held by the "base" gen table and, indirectly via a
* one-to-many relation, the "referenced" gen table.
* The "mapped by" attribute (field/property) name is set while the
* "base" table is calculating its attribute names.
*/
class ManyToOneRelation {
private final GenTable baseGenTable; // the "many" side (e.g. Detail)
private final ForeignKey foreignKey;
private final GenTable referencedGenTable; // the "one" side (e.g. Master)
private String mappedBy; // set while generating entities; used by partner one-to-many relation
ManyToOneRelation(
GenTable baseGenTable,
ForeignKey foreignKey,
GenTable referencedGenTable
) {
super();
this.baseGenTable = baseGenTable;
this.foreignKey = foreignKey;
this.referencedGenTable = referencedGenTable;
referencedGenTable.addOneToManyRelation(new OneToManyRelation(this));
}
GenTable getBaseGenTable() {
return this.baseGenTable;
}
ForeignKey getForeignKey() {
return this.foreignKey;
}
GenTable getReferencedGenTable() {
return this.referencedGenTable;
}
String getAttributeName() {
return this.foreignKey.getAttributeName();
}
String getMappedBy() {
return this.mappedBy;
}
void setMappedBy(String mappedBy) {
this.mappedBy = mappedBy;
}
String getBaseEntityName() {
return this.baseGenTable.getEntityName();
}
String getReferencedEntityName() {
return this.referencedGenTable.getEntityName();
}
EntityGenerator.Config getEntityConfig() {
return this.baseGenTable.getEntityConfig();
}
@Override
public String toString() {
return StringTools.buildToStringFor(this, this.foreignKey);
}
}
|