blob: b53814f9e450522a258af2856800d5fa717d883b [file] [log] [blame]
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>3.&nbsp; Meet-in-the-Middle Mapping</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_mapping.html" title="Chapter&nbsp;7.&nbsp; Mapping"><link rel="prev" href="ref_guide_pc_reverse.html" title="2.&nbsp; Reverse Mapping"><link rel="next" href="ref_guide_mapping_defaults.html" title="4.&nbsp; Mapping Defaults"></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">3.&nbsp;
Meet-in-the-Middle Mapping
</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ref_guide_pc_reverse.html">Prev</a>&nbsp;</td><th width="60%" align="center">Chapter&nbsp;7.&nbsp;
Mapping
</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="ref_guide_mapping_defaults.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_mapping_middle"></a>3.&nbsp;
Meet-in-the-Middle Mapping
</h2></div></div></div><a class="indexterm" name="d0e24555"></a><a class="indexterm" name="d0e24558"></a><a class="indexterm" name="d0e24563"></a><p>
In the <span class="emphasis"><em>meet-in-the-middle</em></span>
mapping approach, you control both the relational model and the object model. It
is up to you to define the mappings between these models. The mapping
tool's <code class="literal">validate</code> action is useful to meet-in-the-middle
mappers. This action verifies that the mapping information for a class matches
the class definition and the existing schema. It throws an informative exception
when your mappings are incorrect.
</p><div class="example"><a name="ref_guide_mapping_mappingtool_validate"></a><p class="title"><b>Example&nbsp;7.11.&nbsp;
Validating Mappings
</b></p><div class="example-contents"><pre class="programlisting">
java org.apache.openjpa.jdbc.meta.MappingTool -action validate Magazine.java
</pre></div></div><br class="example-break"><p>
The <code class="literal">buildSchema</code> action we discussed in
<a href="ref_guide_mapping.html#ref_guide_mapping_mappingtool" title="1.&nbsp; Forward Mapping">Section&nbsp;1, &#8220;
Forward Mapping
&#8221;</a> is also somewhat useful
during meet-in-the-middle mapping. Unlike the <code class="literal">validate</code>
action, which throws an exception if your mapping data does not match the
existing schema, the <code class="literal">buildSchema</code> action assumes your mapping
data is correct, and modifies the schema to match your mappings. This lets you
modify your mapping data manually, but saves you the hassle of using your
database's tools to bring the schema up-to-date.
</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ref_guide_pc_reverse.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="ref_guide_mapping.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="ref_guide_mapping_defaults.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">2.&nbsp;
Reverse Mapping
&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="manual.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;4.&nbsp;
Mapping Defaults
</td></tr></table></div></body></html>