Mongodb For Java Developers Design Build And Deliver Efficient Java Applications Using The Most Advanced Nosql Database Onlineausg Francesco pdf download
Mongodb For Java Developers Design Build And Deliver Efficient Java Applications Using The Most Advanced Nosql Database Onlineausg Francesco pdf download
Mongodb For Jobseekers Reach New Heights In Your Career With Mongodb
Justin Jenkins
https://ebookbell.com/product/mongodb-for-jobseekers-reach-new-
heights-in-your-career-with-mongodb-justin-jenkins-51679966
https://ebookbell.com/product/pentaho-analytics-for-mongodb-
cookbook-1st-edition-latino-joel-55144806
https://ebookbell.com/product/cosmos-db-for-mongodb-developers-
migrating-to-azure-cosmos-db-and-using-the-mongodb-api-1st-ed-manish-
sharma-55145010
https://ebookbell.com/product/data-modeling-for-mongodb-building-
welldesigned-and-supportable-mongodb-databases-steve-hoberman-5048098
Pentaho Analytics For Mongodb Bo Borland
https://ebookbell.com/product/pentaho-analytics-for-mongodb-bo-
borland-5411230
50 Tips And Tricks For Mongodb Developers Get The Most Out Of Your
Database 1st Edition Kristina Chodorow
https://ebookbell.com/product/50-tips-and-tricks-for-mongodb-
developers-get-the-most-out-of-your-database-1st-edition-kristina-
chodorow-55145008
https://ebookbell.com/product/mongodb-and-python-patterns-and-
processes-for-the-popular-documentoriented-database-ohiggins-22034546
Mongodb And Php Documentoriented Data For Web Developers Steve Francia
https://ebookbell.com/product/mongodb-and-php-documentoriented-data-
for-web-developers-steve-francia-5471214
The Definitive Guide To Mongodb The Nosql Database For Cloud And
Desktop Computing 1st Edition Eelco Plugge
https://ebookbell.com/product/the-definitive-guide-to-mongodb-the-
nosql-database-for-cloud-and-desktop-computing-1st-edition-eelco-
plugge-2246960
MongoDB for Java Developers
Francesco Marchioni
BIRMINGHAM - MUMBAI
MongoDB for Java Developers
All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the author, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
ISBN 978-1-78528-027-6
www.packtpub.com
Credits
Reviewers Proofreader
Daniel Mühlbachler Safis Editing
Weiwei Sun
Mehdi Tazi Indexer
Tejal Soni
Commissioning Editor
Veena Pagare Production Coordinator
Aparna Bhagat
Acquisition Editors
James Jones Cover Work
Aparna Bhagat
Nadeem N. Bagban
Technical Editor
Bharat Patil
Copy Editors
Merilyn Pereira
Laxmi Subramanian
About the Author
Over the past 5 years, he has been authoring technical articles for OReilly Media and
running an IT portal focused on JBoss products (http://www.mastertheboss.com).
Daniel enjoys solving challenging problems and is always keen on working with new
technologies, especially related to the fields of big data, functional programming,
optimization, and NoSQL databases.
More detailed information about his experience , as well as his contact details, can be
found at www.muehlbachler.org and www.linkedin.com/in/danielmuehlbachler.
Weiwei Sun is a student of Southeast University, China, and also a student of
Monash University, Australia. He also has a double master's degree in computer
technology and information technology. He loves technology, programming, and
open source projects.
His research interests are database technology, data visualization, and application of
machine learning.
His core expertise involves managing agile scrum teams, as well as architecting
new solutions, and working with multiple technologies, such as JAVA/JEE, Spring,
MongoDB, Cassandra, HTML5, Bootstrap, and AngularJS.
Did you know that Packt offers eBook versions of every book published, with PDF
and ePub files available? You can upgrade to the eBook version at www.PacktPub.
com and as a print book customer, you are entitled to a discount on the eBook copy.
Get in touch with us at [email protected] for more details.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital
book library. Here, you can search, access, and read Packt's entire library of books.
Why subscribe?
• Fully searchable across every book published by Packt
• Copy and paste, print, and bookmark content
• On demand and accessible via a web browser
[ ii ]
Table of Contents
[ iii ]
Table of Contents
[ iv ]
Preface
The NoSQL movement is growing in relevance, and it is attracting more and more
developers. The MongoDB database is a well-recognized rising star in the NoSQL
world. It is a document database that allows data to persist and query data in a
nested state without any schema constraint and complex joins between documents.
Understanding when it is appropriate to use MongoDB against a relational database
and the interfaces to be used to interact with it requires some degree of experience.
This book provides all the knowledge to make MongoDB fit into your application
schema, at the best of its capabilities. It starts from a basic introduction to the driver
that can be used to perform some low level interaction with the storage. Then it
moves on to use different patterns for abstracting the persistence layer into your
applications, starting from the flexible Google JSON library, to the Hibernate OGM
framework, and finally landing on the Spring Data framework.
Chapter 2, Getting Started with Java Driver for MongoDB, introduces the Java
Driver for MongoDB using a simple Java project developed with the NetBeans
development environment.
Chapter 3, MongoDB CRUD Beyond the Basics, covers the advanced usage of the
MongoDB Java driver such as data mapping, index creation, and bulk operations.
[v]
Preface
Chapter 5, Managing Data Persistence with MongoDB and JPA, covers the development
of a Java Enterprise application using Hibernate Object/Grid Mapper (OGM), which
provides Java Persistence API (JPA) support for NoSQL databases.
Chapter 6, Building Applications for MongoDB with Spring Data, teaches you how
to use Spring Data and Spring Boot to leverage micro services using MongoDB
as the storage.
Conventions
In this book, you will find a number of styles of text that distinguish between
different kinds of information. Here are some examples of these styles, and an
explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions,
pathnames, dummy URLs, user input, and Twitter handles are shown as follows:
"In command prompt, navigate to the bin directory present into the mongodb
installation folder and point to the folder where data is stored."
[ vi ]
Preface
When we wish to draw your attention to a particular part of a code block, the
relevant lines or items are set in bold:
MongoClient mongoClient = new MongoClient( "localhost" , 27017 );
DB db = mongoClient.getDB( "test" );
System.out.println("Successfully connected to MongoDB");
New terms and important words are shown in bold. Words that you see on the
screen, in menus or dialog boxes for example, appear in the text like this: " Now let's
add a Java class to the project. From the File menu, select Java Class under New ".
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about
this book—what you liked or may have disliked. Reader feedback is important for
us to develop titles that you really get the most out of.
If there is a topic that you have expertise in and you are interested in either writing
or contributing to a book, see our author guide on www.packtpub.com/authors.
[ vii ]
Preface
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to
help you to get the most from your purchase.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do
happen. If you find a mistake in one of our books—maybe a mistake in the text or the
code—we would be grateful if you would report this to us. By doing so, you can save
other readers from frustration and help us improve subsequent versions of this book.
If you find any errata, please report them by visiting http://www.packtpub.com/
submit-errata, selecting your book, clicking on the errata submission form link,
and entering the details of your errata. Once your errata are verified, your submission
will be accepted and the errata will be uploaded on our website, or added to any list
of existing errata, under the Errata section of that title. Any existing errata can be
viewed by selecting your title from http://www.packtpub.com/support.
Piracy
Piracy of copyright material on the Internet is an ongoing problem across all media.
At Packt, we take the protection of our copyright and licenses very seriously. If you
come across any illegal copies of our works, in any form, on the Internet, please
provide us with the location address or website name immediately so that we can
pursue a remedy.
We appreciate your help in protecting our authors, and our ability to bring you
valuable content.
Questions
You can contact us at [email protected] if you are having a problem with
any aspect of the book, and we will do our best to address it.
[ viii ]
Chapter 1
Introduction to MongoDB
In this book, you will learn how to develop Java applications using the MongoDB
database, which is an open source document-oriented database, recognized as a
rising star in the NoSQL world. In a nutshell, MongoDB is a document database,
which allows data to persist in a nested state, and importantly, it can query that
nested data in an ad hoc fashion. It enforces no schema, so documents can optionally
contain fields or types that no other document in the collection contains.
This seems quite a generic definition of NoSQL databases; however, all databases
that fall into this category have some characteristics in common such as:
• Storing data in many formats: Almost all RDBMS databases are based on
the storage or rows in tables. NoSQL databases, on the other hand, can use
different formats such as document stores, graph databases, key-value stores
and even more.
[1]
Discovering Diverse Content Through
Random Scribd Documents
and others each lay several millions of eggs. The adults rarely pay any
attention to the eggs, which are hatched directly by the heat of the sun
or by heat absorbed from the water. The length of incubation varies
much. When the young fish leaves the egg-shell it carries, in the case of
most species, a part of the yolk still hanging to its body. Its eyes are
very large, and its fins are represented by thin strips of membrane. It
usually undergoes no great changes in development from the first,
resembling the adult except in size. But some of the ocean fishes show a
metamorphosis almost as striking as that of insects or toads or frogs.
Some fishes build nests. Sticklebacks build elaborate nests in the brooks
and defend them with spirit. Sunfishes do the same, but the nests are
clumsier and not so well cared for.
The salmon is the type of fishes which run up from the sea to lay their
eggs in fresh water. The king salmon of the Columbia River, for example,
leaves the sea in the high waters of March and ascends without feeding
for over a thousand miles, depositing its spawn in some small brook in
the fall. After making this long journey to lay the eggs, the salmon
become much exhausted, battered and worn, and are often attacked by
parasitic fungi. They soon die, probably none of them ever surviving to
lay eggs a second time.
Classification.—A fish is an aquatic vertebrate, fitted to breathe the air
contained in water, and never developing fingers and toes. Accepting
this broad general definition we find at once that there are very great
differences among fishes. Some differ more from others than the
ordinary forms differ from rabbits or birds. So although we have entitled
this chapter as if all fishes belonged to the class Pisces, we cannot
arrange them satisfactorily in less than three classes.
The lancelets (Leptocardii).—The lowest class of fish-like animals is
that of the lancelets, the Leptocardii. These little creatures, translucent,
buried in the sand, of the size and form of a small toothpick, are fishes
reduced to their lowest terms. They have the form, life, and ways of a
fish, but no differentiated skull, brain, heart, or eyes. Moreover they
have no limbs, no jaws, no teeth, no scales. The few parts they do have
are arranged as in a fish, and they show something in common with the
fish embryo. Lacking a distinct head, the lancelets are put by some
zoologists in a group called the Acrania, as opposed to the Craniata,
which includes all the other vertebrates. Lancelets have been found in
the North Atlantic and Mediterranean, on the west coast of North
America, on the east coast of South America and on the coasts of Japan,
Australia, New Zealand, the East Indies and Malayan Islands. The best-
known members of the group belong to the genus Amphioxus. There are
but one to two other genera in the class.
Many of the ocean fishes are of strange form and appearance. The
sea-horses (Hippocampus sp.) (fig. 117) are odd fishes covered with
a bony shell and with the head having the physiognomy of that of a
horse. They are little fishes rarely a foot long, and cling by their
curved tails to floating seaweed. The pipefish (Syngnathus fuscum) is
a sea-horse straightened out. The porcupine-fishes and swellfishes
(Tetraodontidæ) have the power of filling the stomach with air which
they gulp from the surface. They then escape from their pursuers by
floating as a round spiny ball on the surface. The flying-fishes
(Exocœtus) leap out of the water and sail for long distances through
the air, like grasshoppers. They cannot flap their long pectoral fins
and do not truly fly; nevertheless they move swiftly through the air
and thus escape their pursuers. In its structure a flying-fish differs
little from a pike or other ordinary fish.
For an account of the fishes of North
America see Jordan's "Manual of
Vertebrates," eighth edition, pp. 5-
173, and Jordan and Evermann's
"Fishes of North and Middle
America," where the 3,127 species
known from our continent are
described in detail with illustrative
figures.
Habits and adaptations.—The
chief part of a fish's life is devoted to
eating, and as most fishes feed on
other fishes, all are equally Fig. 117.—A sea-horse, Hippocampus
considerably occupied in providing heptagonus
Goode.)
. (After
Fig. 118.—The remora, or cling fish, Remoropsis brachyptera. Note sucker on top
of head. (After Goode.)
CHAPTER XXV
OTHER BATRACHIANS.
CHAPTER XXVI
Note that the duct running off from the gall-bladder to the intestine
passes through a pink glandular organ, the pancreas. At the anterior
end of the pancreas is a dark-red nodular structure, the spleen. The
alimentary canal, the liver and the spleen are all suspended from the
dorsal wall of the body-cavity by a delicate sheet of tissue. What is
this? This condition we have also noted in the toad and fish.
Toward the posterior end of the body cavity are two long, dark-red
glands, the kidneys, which are the principal excretory organs of the
body. Through a long, slender tube (the ureter) each of the kidneys
passes off its wastes. Where do the ureters open?
Anterior to the kidneys are the reproductive organs. The eggs,
produced by the female snake, after being fertilized, pass backward
through the egg-tubes. During the breeding season these tubes are
much distended. This is due to the presence of the developing eggs,
for the young snakes are hatched in the egg-tubes.
A successful injection as directed in the first technical note will have
filled both arterial and venous systems. How does the general shape
of the snake's heart compare with that of the toad? The heart
consists of two ventricles, incompletely separated, and two auricles.
In the snake the conus arteriosus is very much shortened and is not
visible. Note two large vessels arising from the median portion of the
ventricle. The one on the left side is the left aortic artery or left aortic
arch, while the right gives off two branches. Where does the anterior
one of these run? The main branch, or right aortic arch, passes back
to meet its fellow, the left aortic artery, forming with it the dorsal
aorta, which runs posteriorly to the end of the tail. Note the various
branches given off by the dorsal aorta and trace some of them.
Arising from the ventricles beneath the two aortic arches is the
pulmonary artery, which goes to the lung. There the blood is
purified, after which it is taken up by the pulmonary vein and carried
back to the left auricle, whence it passes into the ventricle to be
mixed with the impure blood from the right auricle. From the arteries
the blood flows to all parts of the body through fine capillaries,
bathing the tissues, giving off oxygen and taking up the carbonic acid
gas. From these capillaries it passes into veins and so back to the
heart; from the anterior end of the body through the jugular veins
and from the posterior portion of the body through the postcaval
vein. Flowing forward from the tail in the caudal vein, the blood
enters the capillaries of the kidneys, where the waste matter is taken
from it. This part of the circulatory system is known as the renal-
portal circulation. From the kidneys the blood flows through the
postcaval vein anteriorly to the heart.
The blood which passes out from the dorsal aorta to all parts of the
alimentary canal is again collected into veins which unite to form the
mesenteric vein. This vein runs to the liver, where it breaks up into
capillaries. Thence the blood is carried into the postcaval vein, which
leads directly to the heart. This part of the circulatory system which
collects blood from the alimentary canal and carries it to the liver is
called the hepatic-portal system.
Just in front of the heart will be noted a nodular structure, the
thyroid gland, while a little in advance of the thyroid may be seen a
long glandular mass, the thymus gland. The functions of these
glands are not certainly understood.
Remove the alimentary canal and muscles from a part of the body
and note that the axial skeleton, like that of the other vertebrates
studied, consists of a series of vertebræ placed end to end. Are there
arms or legs? Are shoulder and pelvic girdles present? How many of
the vertebræ bear ribs? The ribs connect at their lower ends with the
ventral scales. Note the great number of the vertebræ and ribs as
compared with those of the toad or fish. What are those vertebræ
called which bear no appendages or ribs? Examine carefully the
elongated skull of the snake, especially the modified jaws. A detailed
study of the skeleton may be made by referring to the account of the
skeleton of the lizard in Parker's "Zootomy," pp. 130 et seq.
The nervous system may be worked out in a specimen which has
been immersed in 20 per cent nitric acid. The description of the
nervous system of the toad (see pp. 12-13) will suffice for a guide to
the study of the nervous system of the snake. The special sense
organs, as eyes and ears, should be examined and compared with
those of the fish and toad.
Life-history and habits.—The garter snakes are more or less
aquatic in habit and are good swimmers. They are often found far
from water, but in greatest abundance where the cat-tails and rushes
grow thickest. They feed on frogs, salamanders, and field-mice,
which they swallow whole. All the garter snakes are ovoviviparous,
i.e., hatch eggs within the body-cavity. The eggs, often as many as
eighteen or twenty, are enclosed within widened portions of the
oviducts during embryonic existence; when the young are born they
are able to shift for themselves. During cold weather the garter
snake hibernates, hiding then in some gopher-hole, or, in the warmer
climates, under some log or stone, there to lie dormant until the
warm days of spring come, when it resumes activity.
The garter snake sheds its skin at least once a year, sometimes
oftener. This process may be observed in snakes kept in confinement.
For some time before molting the animal remains torpid, the eyes
become milky, and the skin loses its lustre. After a few days it
conceals itself, the skin about the lips and snout pulls away and the
animal slips out of its entire skin. The snake not only sheds the skin
of the body but also the covering of the eyes. Snakes have no
eyelids, as we have already noted, that which represents the eyelid
being a transparent membrane which covers the eyeball.
No species of the garter snake group is poisonous. Sometimes a
garter snake may appear to be vicious, but its teeth are very short
and at best it can only make a small scratch scarcely piercing the
skin.
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
ebookbell.com