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.

Database Management Systems (3rd Edition)

Autonomic Computing: Concepts, Infrastructure, and Applications

A Practical Guide to SysML: The Systems Modeling Language

HTML Dog: The Best-Practice Guide to XHTML and CSS

Graph Databases





















first and second players, P1 and P2, and the second tournament,T2, includes the first, second, and third players, P1, P2, and P3.) Figure 2-4.  A bidirectional many-to-many association in a relational model representation—test case 29 Chapter 2 ■ Hibernate OGM and MongoDB Now, let’s look at the Hibernate OGM strategies for storing associations, using this test case. We want to observe how the junction table is stored in MongoDB based on the selected strategy. We’ll begin with the default

static final ServiceRegistry serviceRegistry; ... OgmConfiguration cfgogm = new OgmConfiguration(); cfgogm.configure(); serviceRegistry = new ServiceRegistryBuilder(). applySettings(cfgogm.getProperties()).buildServiceRegistry(); sessionFactory = cfgogm.buildSessionFactory(serviceRegistry); ...   This approach (using either Hibernate 3 or 4) requires a hibernate.cfg.xml file that contains specific configurations. For Hibernate OGM, the file needs to contain the correct transaction strategy and

log.log(Level.SEVERE, "Persist failed...", re); throw re; } } }   But, if you want to control the session flush and close by yourself, choose the Hibernate openSession approach, which can be interwoven with JBoss JTA in almost the same manner, as in Listing 4-12. Listing 4-12.  The LuckyNumberDAO Class - openSession Approach package hogm.hnapi.dao; ... public class LuckyNumberDAO { ... private static final Logger log = Logger.getLogger(LuckyNumberDAO.class.getName()); ... public void

repository. It comes as a NetBeans project and it was tested under GlassFish AS 3. Hibernate OGM in a non-JTA Environment (RESOURCE_LOCAL, Apache Tomcat 7) In this section we’ll develop a Hibernate OGM application that will run in a not-recommended condition and environment—this is why we saved it for last. The basic idea is that we will use a transaction of type RESOURCE_LOCAL in an non-EE environment (in a Tomcat web container). In other words, we will have the JPA provider implementation

custom generator, as you’ll see. Creating a new Hibernate custom generator is a very simple task if you follow these steps: • create a new class that implements the interface • override the IdentifierGenerator.generate method; provide the generator business logic and return the new primary key as a Serializable object Based on these two steps, I wrote a custom generator that creates primary keys of type: XXXX_long-number (for example,

Download sample