| <html><head> |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| <title>19. MySQL</title><base href="display"><link rel="stylesheet" type="text/css" href="css/docbook.css"><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"><link rel="home" href="manual.html" title="Apache OpenJPA 2.4 User's Guide"><link rel="up" href="supported_databases.html" title="Appendix 2. Supported Databases"><link rel="prev" href="dbsupport_foxpro.html" title="18. Microsoft FoxPro"><link rel="next" href="dbsupport_oracle.html" title="20. 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. |
| MySQL |
| </th></tr><tr><td width="20%" align="left"><a accesskey="p" href="dbsupport_foxpro.html">Prev</a> </td><th width="60%" align="center">Appendix 2. |
| Supported Databases |
| </th><td width="20%" align="right"> <a accesskey="n" href="dbsupport_oracle.html">Next</a></td></tr></table><hr></div><div class="section" id="dbsupport_mysql"><div class="titlepage"><div><div><h2 class="title" style="clear: both">19. |
| MySQL |
| </h2></div></div></div><div class="toc"><dl class="toc"><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" id="example_props_mysql"><p class="title"><b>Example 2.15. |
| 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" id="dbsupport_mysql_query_hints"><div class="titlepage"><div><div><h3 class="title">19.1. |
| 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" id="dbsupport_mysql_query_hints_ex"><p class="title"><b>Example 2.16. |
| 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" id="dbsupport_mysql_issues"><div class="titlepage"><div><div><h3 class="title">19.2. |
| Known issues with MySQL |
| </h3></div></div></div> |
| |
| <div class="itemizedlist"><ul class="itemizedlist" style="list-style-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. 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> </td><td width="20%" align="center"><a accesskey="u" href="supported_databases.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="dbsupport_oracle.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">18. |
| Microsoft FoxPro |
| </td><td width="20%" align="center"><a accesskey="h" href="manual.html">Home</a></td><td width="40%" align="right" valign="top"> 20. |
| Oracle |
| </td></tr></table></div></body></html> |