31.07.2013 Views

MySQL Cluster Tutorial - cdn.oreillystatic.com

MySQL Cluster Tutorial - cdn.oreillystatic.com

MySQL Cluster Tutorial - cdn.oreillystatic.com

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Cluster</strong>JPA<br />

JPA is the Java standard for persistence and different vendors can implement their own<br />

implementation of this API and they can (and do) add proprietary extensions. Three of the<br />

most <strong>com</strong>mon implementations are OpenJPA, Hibernate and Toplink. JPA can be used<br />

within server containers or outside of them (i.e. with either J2EE or J2SE).<br />

OpenJPA > <strong>Cluster</strong>J > NDB API OpenJPA > Connector/J > <strong>MySQL</strong> > NDB API<br />

Insert<br />

Delete<br />

Find (Primary Key reads)<br />

Update<br />

Other queries<br />

Typically a JPA implementation would access the database (for example, <strong>MySQL</strong> <strong>Cluster</strong>)<br />

using JDBC. JDBC gives a great deal of flexibility to the JPA implementer but it cannot<br />

give the best performance when using <strong>MySQL</strong> <strong>Cluster</strong> as there is an internal conversion to<br />

SQL by Connector/J and a subsequent translation from SQL to the C++ NDB API by the<br />

<strong>MySQL</strong> Server. As of <strong>MySQL</strong> <strong>Cluster</strong> 7.1, OpenJPA can be configured to use the high<br />

performance NDB API (via <strong>Cluster</strong>J) for most operations but fall back on JDBC for more<br />

<strong>com</strong>plex queries.<br />

The first implementation of <strong>Cluster</strong>JPA is as an OpenJPA BrokerFactory but in the future,<br />

it may be extended to work with other JPA implementations.<br />

<strong>Cluster</strong>JPA over<strong>com</strong>es <strong>Cluster</strong>J limitations, notably:<br />

• Persistent classes<br />

• Relationships<br />

• Joins in queries<br />

• Lazy loading<br />

• Table and index creation from object model<br />

Typically users base their selection of a JPA solution on factors such as proprietary<br />

extensions, what existing applications already use and (increasingly with <strong>Cluster</strong>JPA)<br />

performance.<br />

The performance of <strong>Cluster</strong>JPA (OpenJPA using <strong>Cluster</strong>J) has been <strong>com</strong>pared with<br />

OpenJPA using JDBC in Figure 4. It should be noted that the performance is significantly<br />

better when using <strong>Cluster</strong>JPA (the yellow bar). It is hoped that in the future the<br />

performance can be improved even further for finds, updates and deletes.<br />

Copyright © 2010, Oracle and/or its affiliates. All rights reserved. 52/81

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!