Instant Access to MongoDB for Java developers design build and deliver efficient Java applications using the most advanced NoSQL database Francesco ebook Full Chapters
Instant Access to MongoDB for Java developers design build and deliver efficient Java applications using the most advanced NoSQL database Francesco ebook Full Chapters
com
https://ebookname.com/product/mongodb-for-java-developers-
design-build-and-deliver-efficient-java-applications-using-
the-most-advanced-nosql-database-francesco/
OR CLICK BUTTON
DOWLOAD EBOOK
https://ebookname.com/product/oracle-database-programming-using-java-
and-web-services-1st-edition-kuassi-mensah/
ebookname.com
https://ebookname.com/product/learn-objective-c-for-java-
developers-1st-edition-james-bucanek/
ebookname.com
https://ebookname.com/product/professional-eclipse-3-for-java-
developers-1st-edition-berthold-daum/
ebookname.com
https://ebookname.com/product/psychoanalysis-and-the-love-of-arabic-
hall-of-mirrors-1st-edition-nadia-bou-ali/
ebookname.com
The Flexible Phenotype A Body Centred Integration of
Ecology Physiology and Behaviour 1st Edition Theunis
Piersma
https://ebookname.com/product/the-flexible-phenotype-a-body-centred-
integration-of-ecology-physiology-and-behaviour-1st-edition-theunis-
piersma/
ebookname.com
https://ebookname.com/product/key-nursing-skills-1st-edition-barbara-
workman/
ebookname.com
Better Than Vegan 101 Favorite Low Fat Plant Based Recipes
That Helped Me Lose Over 200 Pounds 1st Edition Del Sroufe
https://ebookname.com/product/better-than-vegan-101-favorite-low-fat-
plant-based-recipes-that-helped-me-lose-over-200-pounds-1st-edition-
del-sroufe/
ebookname.com
https://ebookname.com/product/materials-and-infrastructures-2-1st-
edition-toree/
ebookname.com
https://ebookname.com/product/statistical-reinforcement-learning-
modern-machine-learning-approaches-1st-edition-masashi-sugiyama/
ebookname.com
Uncovering the Hidden The Works and Life of Der Nister
Gennady Estraikh
https://ebookname.com/product/uncovering-the-hidden-the-works-and-
life-of-der-nister-gennady-estraikh/
ebookname.com
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 service@packtpub.com 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 questions@packtpub.com 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]
Introduction to MongoDB
• Joinless: NoSQL databases are able to extract your data using simple
document-oriented interfaces without using SQL joins.
• Schemaless data representation: A characteristic of NoSQL implementations
is that they are based on a schemaless data representation, with the notable
exception of the Cassandra database (http://cassandra.apache.org/).
The advantage of this approach is that you don't need to define a data
structure beforehand, which can thus continue to change over time.
• Ability to work with many machines: Most NoSQL systems buy you the
ability to store your database on multiple machines while maintaining
high-speed performance. This brings the advantage of leveraging low cost
machines with separate RAM and disk and also supports linear scalability.
On the other hand, all database developers and administrators know the ACID
acronym. It says that database transactions should be:
At first glance, these qualities seem vital. In practice, however, for many
applications, they are incompatible with the availability and performance in
very large environments. As an example, let's suppose that you have developed an
online book store and you want to display how many of each book you have in your
inventory. Each time a user is in the process of buying a book, you need to lock part
of the database until they finish so that every visitors from the world will see the
exact inventory numbers. That works just fine for a small homemade site but not if
you run Amazon.com. For this reason, when we talk about NoSQL databases, or,
generally, if we are designing distributed systems, we might have to look beyond the
traditional ACID properties. As stated by the CAP theorem, coined by Eric Brewer,
the following set of requirements are truly essential when designing applications for
distributed architectures:
• Consistency: This means the database mostly remains adherent to its rules
(constraints, triggers, and so on) after the execution of each operation and
that any future transaction will see the effects of the earlier transactions
committed. For example, after executing an update, all the clients see the
same data.
• Availability: Each operation is guaranteed a response—a successful or failed
execution. This, in practice, means no downtime.
[2]
Chapter 1
• Partition tolerance: This means the system continues to function even if the
communication among the servers is temporarily unreliable (for example, the
servers involved in the transaction may be partitioned into multiple groups,
which cannot communicate with one another).
If you are designing a typical web application that uses a SQL database, most likely,
you are in the CA part of the diagram. This is because a traditional RDBMS is
typically transaction-based (C) and it can be highly available (A). However, it cannot
be Partition Tolerance (P) because SQL databases tend to run on single nodes.
MongoDB, on the other hand, is consistent by default (C). This means if you perform
a write on the database followed by a read, you will be able to read the same data
(assuming that the write was successful).
[3]
Introduction to MongoDB
However, not all NoSQL databases are built with the same focus. An example of
this is CouchDB. Just like MongoDB, it is document oriented and has been built to
scale across multiple nodes easily; on the other hand, while MongoDB (CP) favors
consistency, CouchDB favors availability (AP) in spite of consistency. CouchDB uses
a replication model called Eventual Consistency. In this model, clients can write
data to one database node without waiting for acknowledgment from other nodes.
The system takes care to copy document changes between nodes, so that they can
eventually be in sync.
The following table summarizes the most common NoSQL databases and their
position relative to CAP attributes:
[4]
Chapter 1
The following is a table that contains the advantages and disadvantages of NoSQL
databases:
[5]
Introduction to MongoDB
With an RDBMS, you can update the database in sophisticated ways using SQL and
wrap multiple statements in a transaction to get atomicity and rollback. MongoDB
doesn't support transactions. This is a solid tradeoff based on MongoDB's goal of
being simple, fast, and scalable. MongoDB, however, supports a range of atomic
update operations that can work on the internal structures of a complex document.
So, for example, by including multiple structures within one document (such as
arrays), you can achieve an update in a single atomic way, just like you would do
with an ordinary transaction.
On the other hand, operations that includes multiple documents (often referred to as
multi-document transactions), are conversely not atomic.
So, to sum it up, if your application's requirements can be met via document updates
(also by using nested documents to provide an atomic update), then this is a perfect
use case for MongoDB, which will allow a much easier horizontal scaling of your
application.
On the other hand, if strict transaction semantics (such as a banking application) are
required, then nothing can beat a relational database. In some scenarios, you can
combine both approaches (RDBMS and MongoDB) to get the best of both worlds,
at the price of a more complex infrastructure to maintain. Such hybrid solutions are
quite common; however, you can see them in production apps such as the New York
Times website.
[6]
Exploring the Variety of Random
Documents with Different Content
It was not very far from sunset, and the small birds were already
singing among the boughs, and the deep shadow—the antique and
neglected air and the silence of the place—gave it, in his romantic
eyes, a character of monastic mystery and enchantment.
As he gazed straight up the dark walk towards the house,
suddenly a man turned the corner of the yew hedge that met the
bridge’s parapet close to him, and walking straight up to the door,
with a gruff look at the little boy, shut and locked the wooden door in
his face.
So all was gone for the present. He knew there was no good in
looking through the key-hole, for envious fortune had hung a spray of
sweetbriar so as effectually to intercept the view, and nothing
remained but the dingy chocolate-coloured planks before him, and
the foliage and roses trembling over the old wall.
Many a time again he passed and re-passed the door without a
like good hap.
At length, however, one evening he found the envious wooden
door once more open, and the view again disclosed through the iron
bars.
A very pretty little girl, with golden hair, was standing on tip-toe
near, and with all her soul was striving to reach an apple with a stick
which she held in her tiny fingers.
Seeing him she fixed her large eyes on him, and said, with an air
of command—
“Come, and climb up the tree and get me that apple.”
His heart beat quick—there was nothing he liked better.
“But I can’t get in,” he said, blushing; “the door is locked.”
“Oh! I’ll call mamma—she’ll let you in. Don’t you know mamma?”
“No, I never saw her,” answered the boy.
“Wait there, and I’ll fetch her.”
And so she was gone.
The first flutter of his excitement was hardly over when he heard
steps and voices near, and the little girl returned, holding the hand of
a slight, pale lady, with a very pretty face, dressed all in black. She
had the key in her hand, and smiled gently on the little boy as she
approached. Her face was kind, and at once he trusted her.
“Oh! he has left the inner door open again,” she said, and with a
little nod and smile of welcome she opened the door, and the boy
entered the garden.
Both doors were now shut.
“Look up, little boy,” said the lady in black, with a very sweet voice.
She liked his face. He was a very handsome little fellow, and with
an expression earnest, shy, and bright, and the indescribable
character of refinement too in his face. She smiled more kindly still,
and placing just the tip of her finger under his chin she said—
“You are a gentleman’s son, and you are nicely dressed. What is
your name?”
“My papa’s name is Mr. Henry,” he answered.
“And where do you go to school?”
“I don’t go to school. I say lessons to Mr. Wharton—about half a
mile from this.”
“It is great fun, I suppose, playing with the little boys—cricket, and
all that?”
“I’m not allowed to play with the little boys.”
“Who forbids you?”
“My friends won’t allow me.”
“Who are your friends?”
“I never saw them.”
“Really! and don’t you live with your papa?”
“No, I live with Marjory.”
“Do you mean with your mamma?”
“Oh, no. She died a long time ago.”
“And is your papa rich—why aren’t you with him?”
“He was rich, Granny says, but he grew poor.”
“And where is he now?”
“I don’t know. I’m to go to school,” he said, acquiring confidence
the more he looked in that sweet face. “My friends will send me, in
three years, Granny says.”
“You are a very nice little boy, and I’m sure a good little fellow.
We’ll have tea in a few minutes—you must stay and drink tea with
us.”
The little fellow held his straw hat in his hand, and was looking up
in the face of the lady, whose slender fingers were laid almost
caressingly on his rich brown hair as she looked down smiling, with
eyes in which “the water stood.” Perhaps these forlorn childhoods
had a peculiar interest for her.
“And it is very polite of you taking off your hat to a lady, but put it
on again, for I’m not a bit better than you; and I’ll go and tell them to
get tea now. Dulcibella,” she called. “Dulcibella, this little friend is
coming to drink tea with us, and Amy and he will play here till it
comes, and don’t mind getting up, sit quiet and rest yourself.”
And she signed with her hand, smiling, to repress her attempt to
rise.
“Well, darling, play in sight o’ me, till your mamma comes back,”
said the rheumatic old woman, addressing the little girl; “and ye
mustn’t be pulling at that great rolling-stone; ye can’t move it, and ye
may break your pretty back trying.”
With these and similar injunctions the children were abandoned to
their play.
He found this pretty young lady imperious, but it was pleasant to
be so commanded, and the little boy climbed trees to gather her
favourite apples, and climbed the garden wall to pluck a bit of
wallflower, and at last she said—
“Now, we’ll play ninepins. There’s the box, set them up on the
walk. Yes, that’s right; you have played; who taught you?”
“Granny.”
“Has Granny ninepins?”
“Yes, ever so much bigger than these.”
“Really! So Granny is rich, then?”
“I think so.”
“As rich as mamma?”
“Her garden isn’t so big.”
“Begin, do you; ah, ha! you’ve hit one, and who plays best?”
“Tom Orange does; does your mamma know Tom Orange?”
“I dare say she does. Dulcibella, does mamma know Tom
Orange?”
“No, my dear.”
“No, she doesn’t,” echoed the little girl, “who is he?”
What, not know Tom Orange! How could that be? So he narrated
on that brilliant theme.
“Tom Orange must come to tea with mamma, I’ll tell her to ask
him,” decided the young lady.
So these little wiseacres pursued their game, and then had their
tea, and in about an hour the little boy found himself trudging home,
with a sudden misgiving, for the first time, as to the propriety of his
having made these acquaintances without Granny’s leave.
The kind voice, the beloved smile of Granny received him before
the cottage door.
“Welcome, darlin’, and where was my darlin’, and what kept him
from his old Granny?”
So they hugged and kissed, and then he related all that had
happened, and asked “was it any harm, Granny?”
“Not a bit, darlin’, that’s a good lady, and a grand lady, and a fit
companion for ye, and see how she knew the gentle blood in your
pretty face; and ye may go, as she has asked you, to-morrow
evening again, and as often as she asks ye; for it was only the little
fellows that’s going about without edication or manners, that your
friends, and who can blame them, doesn’t like ye to keep company
with—and who’d blame them, seeing they’re seldom out of mischief,
and that’s the beginning o’ wickedness, and you’re going, but oh!
darlin’, not for three long years, thank God, to a grand school where
there’s none but the best.”
So this chance acquaintance grew, and the lady seemed to take
every week a deeper interest in the fine little boy, so sensitive,
generous, and intelligent, and he very often drank tea with his new
friends.
CHAPTER LIX.
AN OLD FRIEND.
Little Miss Amy had a slight cold, and the next tea-party was put off
for a day. On the evening following Harry’s visit at Stanlake Farm,
Marjory Trevellian being at that time absent in the village to make
some frugal purchases, who should suddenly appear before the little
boy’s eyes, as he lifted them from his fleet upon the pond, but his
friend, Tom Orange, as usual in high and delightful spirits.
Need I say how welcome Tom was? He asked in a minute or two
for Marjory, and took her temporary absence with great good
humour. Tom affected chilliness, and indeed the evening was a little
sharp, and proposed that they should retire to the cottage, and sit
down there.
“How soon do you suppose, youngster, the old hen will come
home?”
“Who?”
“Marjory Daw, down the chimney.”
“Oh, Granny?”
This nickname was the only pleasantry of Mr. Orange which did
not quite please the boy.
Tom Orange here interpolated his performance of the jackdaw,
with his eyelids turned inside out and the pupils quivering, which,
although it may possibly have resembled the jackdaw of heraldry,
was not an exact portraiture of the bird familiar to us in natural
history; and when this was over he asked again—“How soon will she
be home?”
“She walked down to the town, and I think she can’t be more than
about half-way back again.”
“That’s a mile, and three miles an hour is the best of her paces if
she was runnin’ for a pound o’ sausages and a new cap. Heigh ho!
and alas and alack-a-day. No one at home but the maid, and the
maid’s gone to church! I wrote her a letter the day before yesterday,
and I must read it again before she comes back. Where does she
keep her letters?”
“In her work-box on the shelf.”
“This will be it, the wery identical fiddle!” said Tom Orange,
playfully, setting it down upon the little deal table, and, opening it, he
took out the little sheaf of letters from the end, and took them one by
one to the window, where he took the liberty of reading them.
I think he was disappointed, for he pitched them back again into
their nook in the little trunk-shaped box contemptuously.
The boy regarded Tom Orange as a friend of the family so
confidential, and as a man in all respects so admirable and virtuous,
that nothing appeared more desirable and natural than that excellent
person’s giving his attention to the domestic correspondence.
He popped the box back again in its berth. Then he treated the
young gentleman to Lingo’s song with the rag-tag-merry-derry
perrywig and hat-band, &c., and at the conclusion of the
performance admitted that he was “dry,” and with a pleasant wink,
and the tip of his finger pushing the end of his nose a good deal to
the left, he asked him whether he could tell him where Mrs.
Trevellian, who would be deeply grieved if she thought that Tom was
detained for a drink till her return, kept her liquor.
“Yes, I can show you,” said the boy.
“Wait a minute, my guide, my comforter, and friend,” said Tom
Orange; and he ascertained from the door-stone that no one was
inconveniently near.
The boy was getting a tea-cup off the shelf.
“Never mind sugar, my hero, I’ll sweeten it with a thought of
Marjory Daw.”
The boy explained, and led him into the dark nook by the hall door.
Tom Orange, well pleased, moved almost on tiptoe, and looked
curiously and spoke under his breath, as he groped in this twilight.
“Here it is,” said the boy, frankly.
“Where?”
“Here.”
“This!” said Tom, for his friend had uncovered a crock of water.
Tom Orange glared at him and at the water with grotesque
surprise, and the bona fides of the boy and the simplicity of the
situation struck Tom comically, and, exploding good-humouredly, he
sat down in Marjory’s chair and laughed hilariously.
Having satisfied himself by a confidential dialogue that Marjory
Daw had no private bottle of comfort anywhere, this agreeable fellow
so far forgot his thirst, that he did not mind drawing water from the
crock, and talked on a variety of subjects to the young gentleman. In
the course of this conversation he asked him two topographical
questions. One was—
“Did you ever hear of a place called Carwell Grange?”
And the other resembled it.
“Did you ever hear of a place called Wyvern?”
“No.”
“Think, lad. Did you never hear Mrs. Trevellian speak of Wyvern?
Or of Carwell Grange?”
“No.”
“Because there is the tallest mushroom you ever saw in your life
growing there, and it is grown to that degree that it blocks the door
so that the Squire can’t get into his own house, and the mushroom is
counted one of the wonders of the world upon my little word of
honour as a gentleman! And
‘Since there’s neither drink nor victuals,
Suppose, my lord, we play at skittles?’
And if she’s not back by the end of the game, tell her I had to go on
to the bridge to see lame Bill Withershins, and I’ll be back again this
evening, I think, or in the morning at latest.”
The game was played, but Marjory did not appear, and Tom
Orange, entertaining his young friend with a ludicrous imitation of Bill
Withershins’ knock-knees, took his departure, leaving his delighted
companion in the state which Moore describes as being usual—
“When the lamp that lighted
The traveller at first goes out.”
So, having watched Tom till he was quite out of sight, he returned
to his neglected navy on the pond, and delivered his admirable
Crichton’s message to Marjory Daw on her return.
CHAPTER LXI.
THE HOUR AND THE MAN.
“I think, ma’am, the boy’s in the house. You’d best give him up, for
I’ll not go without him. How many rooms have you?”
“Three and a loft, sir.”
The Sergeant stood up.
“I’ll search the house first, ma’am, and if he’s not here I’ll inform
the police and have him in the Hue-and-Cry; and if you have had
anything to do with the boy’s deserting, or had a hand in making
away with him anyhow, I’ll have you in gaol and punished. I must
secure the door, and you can leave the house first, if you like best.”
“Very well, sir,” answered she.
But at this moment came a knocking and crying from within the
press.
“Oh! no—’twasn’t mammy; ’twas I that did it. Don’t take mammy.”
“You see, ma’am, you give useless trouble. Please open that door
—I shall have to force it, otherwise,” he added, as very pale and
trembling she hesitated.
Standing as he might before his commanding officer, stiff, with his
heels together, with his inflexibly serene face, full before her, he
extended his hand, and said simply, “The key, ma’am.”
In all human natures—the wildest and most stubborn—there is a
point at which submission follows command, and there was that in
the serenity of the ex-Sergeant-Major which went direct to the
instinct of obedience.
It was quite idle any longer trying to conceal the boy. With a
dreadful ache at her heart she put her hand in her pocket and
handed him the key.
As the door opened the little boy shrank to the very back of the
recess, from whence he saw the stout form of the Sergeant stooped
low, as his blue, smooth fixed countenance peered narrowly into the
dark. After a few seconds he seemed to discern the figure of the boy.
“Come, you sir, get out,” said the commanding voice of the visitor,
as the cane which he carried in his hand, paid round with wax-end
for some three inches at the extremity, began switching his little legs
smartly.
“Oh, sir, for the love of God!” cried Marjory, clinging to his hand.
“Oh, sir, he’s the gentlest little creature, and he’ll do whatever he’s
bid, and the lovingest child in the world.”
The boy had got out by this time, and looking wonderingly in the
man’s face, was unconsciously, with the wincing of pain, lifting his
leg slightly, for the sting of the cane was quite new to him.
“If I catch you at that work again I’ll give you five dozen,” said his
new acquaintance.
“Is this his?” said he, touching the carpet-bag with his cane.
“Yes, sir, please.”
He took it in his hand, and glanced at the boy—I think it was in his
mind to make him carry it. But the child was slender, and the bag,
conscientiously packed with everything that had ever belonged to
him, was a trifle too heavy.
“Anything else?” demanded the Sergeant-Major.
“This—this, God bless him.”
It was the little box with his ships.
“And this;” and she thrust the griddle cake, broken across and
rolled up in brown paper, into the boy’s pocket.
“And these;” and three apples she had ready, she thrust after
them.
“And ho! my blessed darlin’, my darlin’, darlin’, darlin’.”
He was lifted up against her heart, folded fast, and hugging her
round the neck, they kissed and cried and cried and kissed, and at
last she let him down; and the Sergeant-Major, with the cane under
his arm, the carpet-bag in one hand, and the boy’s wrist firmly held in
the other, marched out of the door.
“That’s enough—don’t follow, woman,” said he, after they had
gone about twenty yards on the path; “and I’ll report you,” he added
with a nod which, with these pleasant words, she might take as a
farewell or not as she pleased.
She stood on the little rising ground by the hawthorn-tree, kissing
her hands wildly after him, with streaming eyes.
“I’ll be sure to see you soon. I’d walk round the world barefoot to
see my pretty man again,” she kept crying after him; “and I’ll bring
the ninepins, I’ll be sure. Mammy’s comin’, my darlin’.”
And the receding figure of the little boy was turned toward her all it
could. He was gazing over his shoulder, with cheeks streaming with
tears, and his little hand waving yearningly back to her until he was
out of sight. And after a while she turned back, and there was their
ninepins’ ground, and the tarn, and her sobs quickened almost to a
scream; and she sat down on the stone bench under the window—
for she could not bear to enter the dark cottage—and there, in Irish
phrase, she cried her fill.
In the meantime Archdale and his companion, or prisoner—which
you will—pursued their march. He still held the boy’s wrist, and the
boy cried and sobbed gently to himself all the way.
When they came down to the little hamlet called Maple Wickets he
hired a boy to carry the carpet-bag to Wunning, four miles further on,
where the Warhampton ’bus passes, as everybody knows, at half-
past twelve o’clock daily.
They resumed their march. The Sergeant was a serenely taciturn
man. He no more thought of addressing the boy than he did of
apostrophising the cane or the carpet-bag. He let him sob on, and
neither snubbed nor consoled him, but carried his head serene and
high, looking straight before him.
At length the novelty of the scene began to act upon the volatility
of childhood.
As he walked by the Sergeant he began to prattle, at first timidly,
and then more volubly.
The first instinct of the child is trust. It was a kind of consolation to
the boy to talk a great deal of his home, and Tom Orange was of
course mentioned with the usual inquiry, “Do you know Tom
Orange?”
“Why so?”
Then followed the list of that facetious and brilliant person’s
accomplishments.
“And are we to go near a place called Wyvern or Carwell Grange?”
asked the boy, whose memory, where his fancy was interested, was
retentive.
“Why so?” again demanded the Sergeant, looking straight before
him.
“Because Tom Orange told me there’s the biggest mushroom in
the world grown up there, and that the owner of the house can’t get
in, for it fills up the door.”
“Tom Orange told you that?” demanded the Sergeant in the same
way.
And the boy, supposing it incredulity on his part, assured him that
Tom, who was truth itself, had told him so only yesterday.
The Sergeant said no more, and you could not have told in the
least by his face that he had made a note of it and was going to
“report” Tom Orange in the proper quarter. And in passing, I may
mention that about three weeks later Tom Orange was peremptorily
dismissed from his desultory employments under Mr. Archdale, and
was sued for stealing apples from Warhampton orchard, and some
minor peccadillos, and brought before the magistrates, among whom
sat, as it so happened, on that occasion, Squire Fairfield of Wyvern,
who was “precious hard on him,” and got him in for more than a
month with hard labour. The urchin hireling with the carpet-bag
trudged on in front as the Sergeant-Major had commanded.
Our little friend, with many a sobbing sigh, and a great load at his
heart, yet was looking about him.
They were crossing a moor with beautiful purple heather, such as
he had never seen before. The Sergeant had let go his wrist. He felt
more at his ease every way.
There were little pools of water here and there which attracted the
boy’s attention, and made him open his box of cork boats and peep
at them. He wondered how they would sail in these dark little nooks,
and at last, one lying very conveniently, he paused at its margin, and
took out a ship and floated it, and another, and another. How quickly
seconds fly and minutes.
He was roused by the distant voice of the Sergeant-Major
shouting, “Hollo, you sir, come here.”
He looked up. The Sergeant was consulting his big silver watch as
he stood upon a little eminence of peat.
By the time he reached him the Sergeant had replaced it, and the
two or three seals and watchkey he sported were dangling at the end
of his chain upon his paunch. The Sergeant was standing with his
heels together and the point of his cane close to the side of his boot.
“Come to the front,” said the Sergeant.
“Give up that box,” said he.
The boy placed it in his hand. He uncovered it, turned over the
little navy with his fingers, and then jerked the box and its contents
over the heath at his side.
“Don’t pick one of ’em up,” said he.
“Move half a pace to the right,” was his next order.
His next command was—
“Hold out your hand.”
The boy looked in his face, surprised.
The Sergeant’s face looked not a bit angrier or a bit kinder than
usual. Perfectly serene.
“Hold out your hand, sir.”
He held it out, and the cane descended with a whistling cut across
his fingers. Another. The boy’s face flushed with pain, and his
deadened hand sunk downward. An upward blow of the cane across
his knuckles accompanied the command, “Hold it up, sir,” and a third
cut came down.
The Sergeant was strong, and could use his wrist dexterously.
“Hold out the other;” and the same discipline was repeated.
Mingled with and above the pain which called up the three great
black weals across the slender fingers of each hand, was the sense
of outrage and cruelty.
The tears sprang to his eyes, and for the first time in his life he
cried passionately under that double anguish.
“Walk in front,” said the Sergeant, serenely.
And squeezing and wringing his trembling hands together, the still
writhing little fellow marched along the path, with a bitterer sense of
desolation than ever.
The ’bus was late at Wunning; and a lady in it, struck by the
beauty and sadness of the little boy’s face, said some kind words,
and seemed to take to him, he thought, with a tenderness that made
his heart fuller; and it was a labour almost too great for him to keep
down the rising sobs and the tears that were every moment on the
point of flowing over. This good Samaritan bought a bag of what
were called “Ginger-bread nuts”—quite a little store; which Archdale
declined leaving at the boy’s discretion. But I am bound to say that
they were served out to him, from day to day, with conscientious
punctuality by the Sergeant-Major, who was strictly to be depended
on in all matters of property; and would not have nibbled at one of
those nuts though his thin lips had watered and not a soul had been
near. He must have possessed a good many valuable military
virtues, or he could not, I presume, have been where he was.
Noulton Farm is a melancholy but not an ugly place. There are a
great many trees about it. They stand too near the windows. The
house is small and old, and there is a small garden with a thick high
hedge round it.
The members of the family were few. Miss Mary Archdale was ill
when they arrived. She was the only child of the ex-Sergeant, who
was a widower; and the new inmate of the house heard of her with a
terror founded on his awe of her silent father.
They entered a small parlour, and the boy sat down in the chair
indicated by the Sergeant. That person hung his hat on a peg in the
hall, and placed his cane along the chimney-piece. Then he rang the
bell.
The elderly woman who was the female staff of the kitchen
entered. She looked frightened, as all that household did, in their
master’s presence, and watched him with an alarmed eye.
“Where’s Miss Mary?”
“A-spitting blood, sir, please.”
“Bring in supper,” said the Sergeant.
The boy sat in fear at the very corner of the table. His grief would
not let him eat, and he sipped a cup of tea that was too hot, and had
neither milk nor sugar enough. The Sergeant snuffed his candle, and
put on a pair of plated spectacles, and looked through his weekly
paper.
While he was so employed there glided into the room a very slight
girl, with large eyes and a very pale face. Her hair was brown and
rich.
The hand with which she held her shawl across was very thin; and
in her pale face and large eyes was a timid and imploring look that
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookname.com