Skip to main content
summaryrefslogtreecommitdiffstats
blob: 2565b9aae0b955d75ca13fc878bdf6d8540abbd3 (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<!-- Run date = January 22, 2008 9:11:15 -->
<meta name="OAC_IGNORE_SKIP_NAV" content="true" />
<title>Create basic mappings</title>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
<meta name="date" content="2005-07-10T12:57:20+08:00" />
<meta name="robots" content="noarchive" />
<meta name="doctitle" content="Create basic mappings" />
<meta name="relnum" content="M5 - Release 2.0.0" />
<meta name="partnum" content="" />
<link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
<link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" />
<link rel="start" href="../../index.htm" title="Home" type="text/html" />
<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
</head>
<body>
<p><a id="BABEEFJA" name="BABEEFJA"></a></p>
<div class="sect3"><!-- infolevel="all" infotype="General" -->
<h1>Create basic mappings</h1>
<p>Use a <span class="bold">Basic Mapping</span> to map an attribute directly to a database column. In the <a href="getting_started006.htm#BABIDCBA">Tutorial Object Model</a>, the <span class="bold">firstName</span> field of the <span class="bold">Employee</span> class maps directly to the F_NAME column of the EMPLOYEE database table.</p>
<ol start="1">
<li>
<p>Select the <span class="bold">Employee</span> entity in the Package Explorer view.</p>
</li>
<li>
<p>In the <a href="ref_persistence_outline.htm#BABEGGFE">JPA Structure view</a>, select the <span class="bold">firstName</span> field of the <span class="bold">Employee</span> entity. The <a href="ref_persistence_map_view.htm#BABIFBAF">JPA Details view (for attributes)</a> displays the properties for the field.</p>
</li>
<li>
<p>In the <span class="gui-object-title">Map As</span> field, select <span class="gui-object-action">Basic</span>. In the Column field, select <span class="bold">F_NAME</span>.</p>
<div class="figure"><a id="sthref30" name="sthref30"></a>
<p class="titleinfigure">Basic Mapping for firstName</p>
<img src="img/persistence_view_firstname.png" alt="JPA Details view for the firstName field." title="JPA Details view for the firstName field." /><br /></div>
<!-- class="figure" --></li>
</ol>
<p>Dali adds the <code>@Column(name="F_NAME")</code> annotation to the entity. In the JPA Structure, the <span class="bold">firstName</span> field is identified as a basic mapping as shown in the following figure:</p>
<div class="figure"><a id="sthref31" name="sthref31"></a>
<p class="titleinfigure">JPA Structure for Employee Entity</p>
<img src="img/persistence_outline_fname.png" alt="The firstName attribute of the Employee entity in the JPA Structure view." title="The firstName attribute of the Employee entity in the JPA Structure view." /><br /></div>
<!-- class="figure" -->
<p>Repeat this procedure to map each of the following fields as <span class="bold">Basic</span> mappings:</p>
<ul>
<li>
<p>Employee entity</p>
<ul>
<li>
<p><span class="bold">lastName</span> field to L_NAME column</p>
</li>
</ul>
</li>
<li>
<p>Address Entity</p>
<ul>
<li>
<p><span class="bold">city</span> field to CITY column</p>
</li>
<li>
<p><span class="bold">country</span> field to COUNTRY column</p>
</li>
<li>
<p><span class="bold">postalCode</span> field to P_CODE column</p>
</li>
<li>
<p><span class="bold">stateOrProvice</span> field to PROVINCE column</p>
</li>
<li>
<p><span class="bold">street</span> field to STREET column</p>
</li>
</ul>
<div align="center">
<div class="inftblnote"><br />
<table class="Note oac_no_warn" summary="" cellpadding="3" cellspacing="0">
<tbody>
<tr>
<td align="left">
<p class="notep1">Note:</p>
Because the <span class="bold">city</span>, <span class="bold">country</span>, and <span class="bold">street</span> fields are named identically to their database columns, Dali automatically maps the fields; no annotations are required.</td>
</tr>
</tbody>
</table>
<br /></div>
<!-- class="inftblnote" --></div>
</li>
<li>
<p>Phone Entity</p>
<ul>
<li>
<p><span class="bold">areaCode</span> field to AREA_CODE column</p>
</li>
<li>
<p><span class="bold">type</span> field to TYPE column</p>
</li>
</ul>
<div align="center">
<div class="inftblnote"><br />
<table class="Note oac_no_warn" summary="" cellpadding="3" cellspacing="0">
<tbody>
<tr>
<td align="left">
<p class="notep1">Note:</p>
Because the <span class="bold">type</span> field is named identically to its database column, Dali automatically maps the field. No annotation is required.</td>
</tr>
</tbody>
</table>
<br /></div>
<!-- class="inftblnote" --></div>
</li>
</ul>
<p>Next, you will <a href="getting_started016.htm#BABGBGHF">Create one-to-one mappings</a>.</p>
</div>
<!-- class="sect3" -->
<!-- Start Footer -->
<div class="footer">
<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
</tr>
</table>
</div>
<!-- class="footer" -->
</body>
</html>

Back to the top