blob: 791100cb65697fce3eeddd6ed057b73516657bd7 [file] [log] [blame]
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>11.&nbsp; Default Schema</title><link rel="stylesheet" href="css/docbook.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.72.0"><link rel="start" href="manual.html" title="Apache OpenJPA User's Guide"><link rel="up" href="ref_guide_dbsetup.html" title="Chapter&nbsp;4.&nbsp; JDBC"><link rel="prev" href="ref_guide_dbsetup_lrs.html" title="10.&nbsp; Large Result Sets"><link rel="next" href="ref_guide_schema_info.html" title="12.&nbsp; Schema Reflection"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">11.&nbsp;
Default Schema
</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ref_guide_dbsetup_lrs.html">Prev</a>&nbsp;</td><th width="60%" align="center">Chapter&nbsp;4.&nbsp;
JDBC
</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="ref_guide_schema_info.html">Next</a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="ref_guide_schema_def"></a>11.&nbsp;
Default Schema
</h2></div></div></div><a class="indexterm" name="d0e20342"></a><p>
It is common to duplicate a database model in multiple schemas. You may have one
schema for development and another for production, or different database users
may access different schemas. OpenJPA facilitates these patterns with the
<a href="ref_guide_conf_jdbc.html#openjpa.jdbc.Schema" title="6.11.&nbsp; openjpa.jdbc.Schema"><code class="literal">openjpa.jdbc.Schema</code>
</a> configuration property. This property establishes a default schema for
any unqualified table names, allowing you to leave schema names out of your
mapping definitions.
</p><p>
The <code class="literal">Schema</code> property also establishes the default schema for
new tables created through OpenJPA tools, such as the mapping tool covered in
<a href="ref_guide_mapping.html#ref_guide_mapping_mappingtool" title="1.&nbsp; Forward Mapping">Section&nbsp;1, &#8220;
Forward Mapping
&#8221;</a>.
</p><p>
If the entities are mapped to the same table name but with different schema
name within one <code class="literal">PersistenceUnit</code> intentionally, and the
strategy of <code class="literal">GeneratedType.AUTO</code> is used to generate the ID
for each entity, a schema name for each entity must be explicitly declared
either through the annotation or the mapping.xml file. Otherwise, the mapping
tool only creates the tables for those entities with the schema names under
each schema. In addition, there will be only one
<code class="literal">OPENJPA_SEQUENCE_TABLE</code> created for all the entities within
the <code class="literal">PersistenceUnit</code> if the entities are not identified
with the schema name.
Read <a href="ref_guide_sequence.html" title="6.&nbsp; Generators">Section&nbsp;6, &#8220;
Generators
&#8221;</a> in the Reference Guide.
</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ref_guide_dbsetup_lrs.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="ref_guide_dbsetup.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="ref_guide_schema_info.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">10.&nbsp;
Large Result Sets
&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="manual.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;12.&nbsp;
Schema Reflection
</td></tr></table></div></body></html>