blob: bc7a38681aa37a8aa8a8cf48f1b76c8ba2225041 [file] [log] [blame]
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>19.&nbsp; MySQL</title><base href="display"><link rel="stylesheet" type="text/css" href="css/docbook.css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.76.1"><link rel="home" href="manual.html" title="Apache OpenJPA 2.3 User's Guide"><link rel="up" href="supported_databases.html" title="Appendix&nbsp;2.&nbsp; Supported Databases"><link rel="prev" href="dbsupport_foxpro.html" title="18.&nbsp; Microsoft FoxPro"><link rel="next" href="dbsupport_oracle.html" title="20.&nbsp; Oracle"></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">19.&nbsp;
MySQL
</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="dbsupport_foxpro.html">Prev</a>&nbsp;</td><th width="60%" align="center">Appendix&nbsp;2.&nbsp;
Supported Databases
</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="dbsupport_oracle.html">Next</a></td></tr></table><hr></div><div class="section" title="19.&nbsp; MySQL"><div class="titlepage"><div><div><h2 class="title" style="clear: both" id="dbsupport_mysql">19.&nbsp;
MySQL
</h2></div></div></div><div class="toc"><dl><dt><span class="section"><a href="dbsupport_mysql.html#dbsupport_mysql_query_hints">19.1.
Using Query Hints with MySQL
</a></span></dt><dt><span class="section"><a href="dbsupport_mysql.html#dbsupport_mysql_issues">19.2.
Known issues with MySQL
</a></span></dt></dl></div>
<div class="example"><a name="example_props_mysql"></a><p class="title"><b>Example&nbsp;2.15.&nbsp;
Example properties for MySQL
</b></p><div class="example-contents">
<pre class="programlisting">
openjpa.ConnectionDriverName: com.mysql.jdbc.Driver
openjpa.ConnectionURL: jdbc:mysql://SERVER_NAME/DB_NAME
</pre>
</div></div><br class="example-break">
<div class="section" title="19.1.&nbsp; Using Query Hints with MySQL"><div class="titlepage"><div><div><h3 class="title" id="dbsupport_mysql_query_hints">19.1.&nbsp;
Using Query Hints with MySQL
</h3></div></div></div>
<p>
MySQL has support for "query hints", which are keywords embedded in
SQL that provide some hint for how the query should be executed. These hints are
usually designed to provide suggestions to the MySQL query optimizer for how to
efficiently perform a certain query, and aren't typically needed for any but
the most intensive queries.
OpenJPA supports hints to be placed between SELECT keyword and column list.
</p>
<div class="example"><a name="dbsupport_mysql_query_hints_ex"></a><p class="title"><b>Example&nbsp;2.16.&nbsp;
Using MySQL Hints
</b></p><div class="example-contents">
<pre class="programlisting">
Query query = em.createQuery(...);
query.setHint("openjpa.hint.MySQLSelectHint", "SQL_NO_CACHE");
List results = query.getResultList();
</pre>
</div></div><br class="example-break">
</div>
<div class="section" title="19.2.&nbsp; Known issues with MySQL"><div class="titlepage"><div><div><h3 class="title" id="dbsupport_mysql_issues">19.2.&nbsp;
Known issues with MySQL
</h3></div></div></div>
<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
<p>
The default table types that MySQL uses do not support transactions, which will
prevent OpenJPA from being able to roll back transactions. Use the
<code class="literal">InnoDB</code> table type for any tables that OpenJPA will access.
</p>
</li><li class="listitem">
<p>
MySQL does not support sub-selects in versions prior to 4.1, so
some operations (such as the <code class="function">isEmpty()</code> method in a
query) will fail due to this.
</p>
</li><li class="listitem">
<p>
Rollback due to database error or optimistic lock violation is not supported
unless the table type is one of the MySQL transactional types. Explicit calls to
<code class="function">rollback()</code> before a transaction has been committed,
however, are always supported.
</p>
</li><li class="listitem">
<p>
Floats and doubles may lose precision when stored in some datastores.
</p>
</li><li class="listitem">
<p>
When storing a field of type <code class="classname">java.math.BigDecimal</code>, some
datastores will add extraneous trailing 0 characters, causing an equality
mismatch between the field that is stored and the field that is retrieved.
</p>
</li><li class="listitem">
<p>
When using large result sets with MySQL there are a number of documented limitations.
Please read the section titled "ResultSet" in the "MySQL JDBC API Implementation Notes".
The net effect of these limitations is that you will have to read all of the rows of a
result set (or close the connection) before you can issue any other queries on
the connection, or an exception will be thrown. Setting openjpa.FetchBatchSize
to any value greater than zero will enable streaming result sets.
</p>
</li><li class="listitem">
<p>
The use of <a class="link" href="ref_guide_mapping_jpa.html#ref_guide_streamsupport" title="7.11.&nbsp; LOB Streaming">LOB streaming</a> is limited.
When reading LOB data from the database, the MySQL JDBC driver will actually
load all the data into memory at the same time.
</p>
</li></ul></div>
</div>
</div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="dbsupport_foxpro.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="supported_databases.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="dbsupport_oracle.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">18.&nbsp;
Microsoft FoxPro
&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="manual.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;20.&nbsp;
Oracle
</td></tr></table></div></body></html>