Introduction

This book covers all the important aspects of developing Hibernate OGM-MongoDB applications. It provides clear instructions for getting the most out of the Hibernate OGM-MongoDB duo and offers many examples of integrating Hibernate OGM by means of both the Hibernate Native API and the Java Persistence API. You will learn how to develop desktop, web, and enterprise applications for the most popular web and enterprise servers, such as Tomcat, JBoss AS, and Glassfish AS. You’ll see how to take advantage of Hibernate OGM-MongoDB together with many common technologies, such as JSF, Spring, Seam, EJB, and more. Finally, you’ll learn how to migrate to the cloud—MongoHQ, MongoLab, and OpenShift.

Who This Book Is For

This book is for experienced Java developers who are interested in exploring Hibernate solutions for NoSQL databases. For the opening chapters (Chapters 13), it’s enough to be familiar with the main aspects of the ORM paradigm, the Hibernate Native API, and JPA. The book provides brief overviews of these concepts. Starting with Chapter 4, you should have some knowledge about developing web applications (using NetBeans or Eclipse) deployed under the Tomcat, JBoss AS, or GlassFish AS servers. Moreover, you need to be familiar with the Java technologies and frameworks that are commonly used in web applications, such as servlets, EJB, JSF, JSP, Seam, Spring, and so on.

How This Book Is Structured

Here’s the main focus of each chapter:

Chapter 1: Getting Started with Hibernate OGM

This chapter provides a brief introduction to the Hibernate OGM world. In the first part of the chapter, I discuss the Hibernate OGM architecture, its current features, and what we can expect in terms of future support. I then offer several alternatives for downloading, installing, and configuring Hibernate OGM and MongoDB.

Chapter 2: Hibernate OGM and MongoDB1

In this chapter, I define more clearly the relationship between Hibernate OGM and MongoDB by focusing on how Hibernate OGM works with MongoDB. You learn how data is stored, how primary keys and associations are mapped, and how to deal with transactions and queries.

Chapter 3: Bootstrapping Hibernate OGM

This chapter shows how Hibernate OGM can be bootstrapped by means of the Hibernate Native API and JPA.

Chapter 4: Hibernate OGM at Work

This is one of the most important chapters. You learn how to integrate Hibernate OGM and MongoDB in the most common web and enterprise Java applications deployed on different servers. Here is the entire list of applications:

  • Java SE and Mongo DB—a “Hello world” example
  • Hibernate OGM (via Hibernate Native API) in a non-JTA environment (JDBC Transactions, Tomcat 7)
  • Hibernate OGM (via Hibernate Native API) in a standalone JTA environment (JBoss JTA, Tomcat 7)
  • Hibernate OGM (via Hibernate Native API) in a built-in JTA environment (no EJB, GlassFish 3)
  • Hibernate OGM (via Hibernate Native API) in a built-in JTA environment (EJB/BMT, GlassFish 3)
  • Hibernate OGM (via Hibernate Native API) in a built-in JTA environment (EJB/CMT, GlassFish 3)
  • Hibernate OGM (via JPA) in a built-in JTA environment (GlassFish AS 3)
  • Hibernate OGM (via JPA) in a built-in JTA environment (JBoss AS 7)
  • Hibernate OGM (via JPA) in a built-in JTA environment (JBoss AS 7 and Seam application)
  • Hibernate OGM (via JPA) in a built-in JTA environment (GlassFish and Spring application)
  • Hibernate OGM (via JPA) JPA/JTA in a standalone JTA environment (Tomcat)
  • Hibernate OGM in a non- JTA environment (RESOURCE_LOCAL, Apache Tomcat 7)

Chapter 5: Hibernate OGM and JPA 2.0 Annotations

Mapping Java entities in Hibernate OGM can be divided into supported and non-supported annotations. In this chapter, I show the supported annotations, as well as how much of each annotation is supported.

Chapter 6: Hibernate OGM Querying MongoDB

This chapter explores the querying capabilities of Hibernate OGM. I start with a MongoDB native query and progress to complex queries written with Hibernate Search and Apache Lucene.

Chapter 7: MongoDB e-Commerce Database Model

At this point in the book, you will have acquired sufficent expertise to develop a real application that involves Hibernate OGM and MongoDB. An e-commerce web site is a good start and an interesting study case, so in this chapter I adapt a classic SQL database model to the Hibernate OGM and MongoDB style. I also examine aspects of e-commerce database architecture.

Chapter 8: MongoDB e-Commerce Database Querying

After you develop a MongoDB e-commerce database model, it’s time to sketch and implement the main e-commerce-specific queries. In this chapter, I use Hibernate Search and Apache Lucene to write such queries. The result is a complete e-commerce application named RafaEShop.

Chapter 9: Migrate MongoDB Database to Cloud

In this chapter, you learn how to migrate the MongoDB e-commerce database developed in Chapter 7 into two clouds: MongoHQ and MongoLab.

Chapter 10: Migrating RafaEShop Application on OpenShift

This final chapter is a detailed guide for migrating the e-commerce RafaEShop application to the OpenShift cloud on two enterprise servers: JBoss AS and GlassFish AS.

Downloading the Code

The code for the examples shown in this book is available on the Apress web site, www.apress.com. You’ll find the link on the book’s information page under the Source Code/Downloads tab. This tab is located underneath the Related Titles section of the page.

Contacting the Author

Should you have any questions or comments—or even spot a mistake you think I should know about—you can contact me at [email protected].

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset