12.07.2015 Views

Beginning Java EE 6 with GlassFish 3, Second Edition

Beginning Java EE 6 with GlassFish 3, Second Edition

Beginning Java EE 6 with GlassFish 3, Second Edition

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.

CHAPTER 2 ■ JAVA PERSISTENCEorg.apache.derbyderby10.6.1.0testjunitjunit4.8.1testorg.apache.maven.pluginsmaven-compiler-plugintrue1.61.6First, to be able to compile the code, you need the JPA API that defines all the annotations andclasses that are in the javax.persistence package. You will get these classes in a jar referred by thejavax.persistence artifact ID and stored in the Maven repository. The EclipseLink runtime (i.e., thepersistence provider) is defined in the eclipselink artifact ID. You then need the JDBC drivers toconnect to Derby. The derbyclient artifact ID refers to the jar that contains the JDBC driver to connectto Derby running in server mode (the database runs in a separate process and listens to a port) and thederby artifact ID contains the classes to use Derby as an embedded database. Note that this artifact ID isscoped for testing (test) and has a dependency on JUnit 4.To compile the classes, open a command-line interpreter in the root directory that contains thepom.xml file and enter the following Maven command:mvn compileYou should see the BUILD SUCCESSFUL message informing you that the compilation was successful.Maven creates a target subdirectory <strong>with</strong> all the class files as well as the persistence.xml file.55

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

Saved successfully!

Ooh no, something went wrong!