Pro Hibernate and MongoDB (The Expert's Voice)

Pro Hibernate and MongoDB (The Expert's Voice)

Anghel Leonard

Language: English

Pages: 384

ISBN: 1430257946

Format: PDF / Kindle (mobi) / ePub


Hibernate and MongoDB are a powerful combination of open source persistence and NoSQL technologies for today's Java-based enterprise and cloud application developers. Hibernate is the leading open source Java-based persistence, object relational management engine, recently repositioned as an object grid management engine.  MongoDB is a growing, popular open source NoSQL framework, especially popular among cloud application and big data developers.  With these two, enterprise and cloud developers have a "complete out of the box" solution. 

Pro Hibernate and MongoDB shows you how to use and integrate Hibernate and MongoDB.  More specifically, this book guides you through the bootstrap; building transactions; handling queries and query entities; and mappings.  Then, this book explores the principles and techniques for taking these application principles to the cloud, using the OpenShift Platform as a Service (PaaS) and more. 

In this book, you get two case studies:

  • An enterprise application using Hibernate and MongoDB.  then,
  • A cloud application (OpenShip) migrated from the enterprise application case study

After reading or using this book, you come away with the experience from two case studies that give you possible frameworks or templates that you can apply to your own specific application or cloud application building context.

Computational Intelligence in Image Processing

Automating Microsoft Azure with Powershell

Engineering Long-Lasting Software: An Agile Approach Using SaaS and Cloud Computing (Beta Edition)

Applied Semantic Web Technologies

Beginning 3D Game Development with Unity 4: All-in-one, multi-platform game development (2nd Edition)

Algorithm Design: Solutions Manual

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

time to discuss advanced setting for MongoDB, storage principles, JP-QL, Hibernate Search, and so on. General Prerequisites Before we start, make sure you’ve correctly installed MongoDB (as you saw in the Chapter 1) and that you have the Hibernate OGM JARs available, including the JARs needed for MongoDB support (locally or through Maven artifacts). The rest of the tools, such as application servers, frameworks, IDEs and so on, can be installed separately according to your needs; you probably

Eclipse) button to start GlassFish and deploy and run the application. If the application successfully starts, you’ll see in the browser something similar to what’s shown in Figure 4-10. Figure 4-10.  Running the HOGMviaHNAPI_JTA_EJB_CMT_GlassFish3 application Press the Generate Lucky Number button a few times to persist some lucky numbers into the MongoDB database (glassfish_db) collection (cmt). For each press, two new documents are inserted, one for the enitity and one for the POJO. Open a

Eclipse/Tomcat) environment, just save the project and click the Run (or Run on Server in Eclipse) button to start Tomcat and deploy and run the application. If the application successfully starts, you’ll see in your browser something like what’s shown in Figure 4-26. Figure 4-26.  Running the HOGMviaJPA_RESOURCELOCAL_Tomcat7 application Press the Generate Lucky Number button a few times to persist some lucky numbers into the MongoDB database (tomcat_db) collection (jpa_rl). Open a command

generated _id from MongoDB as the primary key for the persisted object. In any case, it’s a well-known fact that this strategy has some problems, especially with regard to portability and performance. Setting the IDENTITY strategy can be accomplished using the @GeneratedValue annotation, like this:   import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; ...   @Entity public class Players implements Serializable {   @Id

Annotations For the COLLECTION strategy, here are the possibilities: • For unidirectional one-to-one associations, COLLECTION has no effect (similar to IN_ENTITY). • For a bidirectional one-to-one association, the navigation information is stored like this: the collection representing the entity that uses mappedBy (the non-owner side of the association) doesn’t contain navigation information; it’s stored in a separate collection prefixed with the word associations (every such association

Download sample

Download