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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 2 ■ JAVA PERSISTENCERunning the BookTest Class <strong>with</strong> Embedded DerbyNothing is easier than running the test: you rely on Maven. Open a console in the directory where thepom.xml file is located and enter the following command:mvn testBecause the logging level has been set to FINE, you should see verbose information about Derbycreating a database and tables in memory. The BookTest class is then executed, and a Maven reportshould inform you that the test is successful.Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 9.415 secResults :Tests run: 1, Failures: 0, Errors: 0, Skipped: 0[INFO] ----------------------------------------------------------------[INFO] BUILD SUCCESSFUL[INFO] ----------------------------------------------------------------[INFO] Total time: 19 seconds[INFO] Finished[INFO] Final Memory: 4M/14M[INFO] ----------------------------------------------------------------SummaryThis chapter contains a quick overview of JPA 2.0. Like most of the other <strong>Java</strong> <strong>EE</strong> 6 specifications, JPAfocuses on a simple object architecture, leaving its ancestor, a heavyweight component model (a.k.a. EJBCMP 2.x), behind. The chapter also covered entities, which are persistent objects that use mappingmetadata through annotations or XML.Thanks to the “Putting It All Together” section, you have seen how to run a JPA application <strong>with</strong>EclipseLink and Derby. Unit testing is an important topic in projects, and, <strong>with</strong> JPA and in memorydatabases such as Derby, it is now very easy to test persistence.In the following chapters, you will learn more about the main JPA components. Chapter 3 will showyou how to map entities, relationships, and inheritance to a database. Chapter 4 will focus on the entitymanager API, the JPQL syntax, and how to use queries and locking mechanisms. Chapter 5, the lastchapter of this JPA section, will explain the life cycle of entities and how to hook business logic incallback methods in entities and listeners.60

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

Saved successfully!

Ooh no, something went wrong!