Skip to main content
summaryrefslogtreecommitdiffstats
blob: 128f64f961df5446c330492d6858411cd8394742 (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
<!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>
<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" />
<title>Generating tables from entities</title>
<meta name="copyright" content="Copyright (c) 2000, 2009 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" />
<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 1.0.11" />
<meta name="date" content="2013-01-03T9:24:53Z" />
<meta name="robots" content="noarchive" />
<meta name="doctitle" content="Generating tables from entities" />
<meta name="relnum" content="Release 3.3" />
<meta name="partnum" content="Release 3.3" />
<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" />
</head>
<body>
<p class="betadraftsubtitle">Beta Draft: 2013-01-03</p>
<p><a id="CIHJIGBE" name="CIHJIGBE"></a></p>
<div class="sect1"><!-- infolevel="all" infotype="General" -->
<h1>Generating tables from entities</h1>
<p><a id="sthref301" name="sthref301"></a><a id="sthref302" name="sthref302"></a><a id="sthref303" name="sthref303"></a>When using a vendor-specific platform, you can create a DDL script from your persistent entities.</p>
<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>
<p>The DDL script will <code>DROP</code> existing tables on the database and <code>CREATE</code> new tables, based on the entities in your project.</p>
</td>
</tr>
</tbody>
</table>
<br /></div>
<!-- class="inftblnote" --></div>
<p>To generate a DDL script:</p>
<ol>
<li>
<p>Right-click the JPA project in the <span class="gui-object-title">Project Explorer</span> and select <span class="gui-object-action">JPA Tools &gt; Generate Tables from Entities</span>.</p>
<img src="img/generate_tables_from_entities.png" alt="JPA Tools &gt; Generate Tables from Entities" title="JPA Tools &gt; Generate Tables from Entities" /><br /></li>
<li>
<p>On the <a href="reference019.htm#CACHAJEG">Schema Generation</a> page, select the generation output mode.</p>
<div class="figure"><a id="sthref304" name="sthref304"></a>
<p class="titleinfigure">Schema Generation</p>
<img src="img/generate_tables.png" alt="" title="" /><br /></div>
<!-- class="figure" --></li>
<li>
<p>Click <span class="bold">Finish</span>. Dali generates the selected DDL for the entities, as shown in <a href="#CIHJAHAC">Example: Sample Generated Output</a>.</p>
</li>
</ol>
<p>If you are not currently connected to the database, the Database Connection page appears. Select your database connection and schema, and click <span class="bold">Reconnect</span>.</p>
<div class="example"><a id="CIHJAHAC" name="CIHJAHAC"></a>
<p class="titleinexample">Sample Generated Output</p>
<pre xml:space="preserve" class="oac_no_warn">
[EL Config]: metadata: The access type for the persistent class [class quickstart.demo.model.Address] is set to [FIELD].
[EL Config]: metadata: The alias name for the entity class [class quickstart.demo.model.Address] is being defaulted to: Address.
[EL Config]: metadata: The table name for entity [class quickstart.demo.model.Address] is being defaulted to: ADDRESS.
[EL Config]: metadata: The column name for element [street] is being defaulted to: STREET.
[EL Config]: metadata: The column name for element [city] is being defaulted to: CITY.
[EL Config]: metadata: The column name for element [country] is being defaulted to: COUNTRY.
[EL Info]: EclipseLink, version: Eclipse Persistence Services - 2.4.0.vXXXX
[EL Fine]: connection: Detected database platform: org.eclipse.persistence.platform.database.JavaDBPlatform
[EL Config]: connection: Connection(7896086)--connecting(DatabaseLogin(
    platform=&gt;JavaDBPlatform
    user name=&gt; ""
    datasource URL=&gt; "jdbc:derby:C:\MyDB;create=true"
))
[EL Config]: connection: Connection(28523022)--Connected: jdbc:derby:C:\MyDB
    User: APP
    Database: Apache Derby  Version: 10.9.1.0 - (XXXX)
    Driver: Apache Derby Embedded JDBC Driver  Version: 10.9.1.0 - (XXXX)
[EL Config]: connection: Connection(27817788)--connecting(DatabaseLogin(
    platform=&gt;JavaDBPlatform
    user name=&gt; ""
    datasource URL=&gt; "jdbc:derby:C:\MyDB;create=true"
))
[EL Config]: connection: Connection(11557581)--Connected: jdbc:derby:C:\MyDB
    User: APP
    Database: Apache Derby  Version: 10.9.1.0 - (XXXX)
    Driver: Apache Derby Embedded JDBC Driver  Version: 10.9.1.0 - (XXXX)
[EL Info]: connection: file:/C:/workspace/runtime-EclipseApplication/QuickStart/build/classes/_QuickStart_url=jdbc:derby:C:\MyDB;create=true login successful
[EL Fine]: sql: Connection(28523022)--DROP TABLE ADDRESS
[EL Fine]: sql: Connection(28523022)--CREATE TABLE ADDRESS (ADDRESS_ID BIGINT NOT NULL, CITY VARCHAR(255), COUNTRY VARCHAR(255), P_CODE VARCHAR(255), PROVINCE VARCHAR(255), STREET VARCHAR(255), PRIMARY KEY (ADDRESS_ID))
[EL Config]: connection: Connection(28523022)--disconnect
[EL Info]: connection: file:/C://workspace/runtime-EclipseApplication/QuickStart/build/classes/_QuickStart_url=jdbc:derby:C:\MyDB;create=true logout successful
[EL Config]: connection: Connection(7896086)--disconnect
[EL Config]: connection: Connection(11557581)--disconnect

</pre></div>
<!-- class="example" -->
<a id="sthref305" name="sthref305"></a>
<p class="subhead2">Related tasks</p>
<ul>
<li>
<p><a href="task_create_jpa_entity.htm#BABFBJBG">Creating a JPA entity</a></p>
</li>
</ul>
<a id="sthref306" name="sthref306"></a>
<p class="subhead2">Related reference</p>
<ul>
<li>
<p><a href="ref_project_properties.htm#BABJHBCI">Project Properties page &ndash; JPA</a></p>
</li>
</ul>
</div>
<!-- class="sect1" -->
<!-- Start Footer -->
<div class="footer">
<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
<col width="86%" />
<col width="*" />
<tr>
<td align="left"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2011, 2013,&nbsp;Oracle&nbsp;and/or&nbsp;its&nbsp;affiliates.&nbsp;All&nbsp;rights&nbsp;reserved.</span><br />
<a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Legal Notices</span></a></td>
</tr>
</table>
</div>
<!-- class="footer" -->
</body>
</html>

Back to the top