Beginning jOOQ: Learn to Write Efficient and Effective Java-Based SQL Database Operations 1st Edition Tayo Koleoso instant download
Beginning jOOQ: Learn to Write Efficient and Effective Java-Based SQL Database Operations 1st Edition Tayo Koleoso instant download
https://ebookmeta.com/product/beginning-jooq-learn-to-write-
efficient-and-effective-java-based-sql-database-operations-1st-
edition-tayo-koleoso-3/
https://ebookmeta.com/product/beginning-jooq-learn-to-write-
efficient-and-effective-java-based-sql-database-operations-1st-
edition-tayo-koleoso-3/
https://ebookmeta.com/product/beginning-jooq-learn-to-write-
efficient-and-effective-java-based-sql-database-operations-1st-
edition-tayo-koleoso/
https://ebookmeta.com/product/effective-sql-61-specific-ways-to-
write-better-sql-1st-edition-john-l-viescas-douglas-j-steele-ben-
g-clothier/
https://ebookmeta.com/product/learning-kali-linux-security-
testing-penetration-testing-and-ethical-hacking-2nd-edition-
first-early-release-ric-messier/
https://ebookmeta.com/product/practical-guide-to-digital-
manufacturing-first-time-right-for-design-of-products-machines-
processes-and-system-integration-zhuming-bi/
https://ebookmeta.com/product/a-final-family-affair-an-extreme-
taboo-anthology-1st-edition-a-a-davies-yolanda-olson-ally-vance-
cole-denton-k-webster-jennifer-bene-winter-paige-3/
https://ebookmeta.com/product/indirect-judicial-review-in-
administrative-law-legality-vs-legal-certainty-in-europe-1st-
edition-mariolina-eliantonio/
https://ebookmeta.com/product/patrick-white-and-god-1st-edition-
michael-giffin/
Im politeness and Moral Order in Online Interactions
1st Edition Chaoqun Xie
https://ebookmeta.com/product/im-politeness-and-moral-order-in-
online-interactions-1st-edition-chaoqun-xie/
Beginning
jOOQ
Tayo Koleoso
Beginning jOOQ
Database Operations
Tayo Koleoso
Database Operations
Tayo Koleoso
https://doi.org/10.1007/978-1-4842-7431-6
While the advice and information in this book are believed to be true
and accurate at the date of publication, neither the authors nor the
editors nor the publisher can accept any legal responsibility for any
errors or omissions that may be made. The publisher makes no
warranty, express or implied, with respect to the material contained
herein.
source- code.
Table of Contents
Database Aware
�������������������������������
�������������������������������
�������������������������������1
1
Code Generation
�������������������������������
�������������������������������
������������������������������11
Type Safety
�������������������������������
�������������������������������
�������������������������������
�������12
Domain-Specific Language
�������������������������������
�������������������������������
�������������12
Tooling
Support����������������������������
�������������������������������
�������������������������������
����13
JVM Languages
�������������������������������
�������������������������������
�������������������������������1
4
Setting Up jOOQ
�������������������������������
�������������������������������
�������������������������������
�����20
iii
Table of ConTenTs
Select Statements
�������������������������������
�������������������������������
���������������������������34
Insert Statements
�������������������������������
�������������������������������
����������������������������63
Update Statements
�������������������������������
�������������������������������
��������������������������66
Delete Statements
�������������������������������
�������������������������������
���������������������������67
Alternative Data Access Modes
�������������������������������
�������������������������������
�������69
Transactions
�������������������������������
�������������������������������
�������������������������������
�����������73
With Locking
�������������������������������
�������������������������������
�������������������������������
�����76
Configuration�������������������������
�������������������������������
�������������������������������
����������������78
Connection Management
�������������������������������
�������������������������������
�����������������79
Query Management
�������������������������������
�������������������������������
�������������������������84
Query Lifecycle Integration
�������������������������������
�������������������������������
��������������86
Generating
Code�����������������������������
�������������������������������
�������������������������������
�������89
Joins
�������������������������������
�������������������������������
�������������������������������
���������������117
Batch Operations
�������������������������������
�������������������������������
���������������������������128
Generate SQL
Queries����������������������������
�������������������������������
�����������������������153
iv
Table of ConTenTs
Index
�������������������������������
�������������������������������
�������������������������������
����211
v
About the Author
vii
MODERN FALLACIES.
No correct ideas of combustion were attained until the time of
Lavoisier.[2] This great French savant gave precision and accuracy to
the investigations of chemical science by the introduction of the
balance. He disproved the theory that “water is the ultimate principle
of all things,” and prepared the way for a clear apprehension of the
truth that matter, though constantly changing its form, is never
destroyed. He also announced the correct theory of combustion.
Until this time scientists had held what was called the “Phlogiston[3]
Theory.” We can but smile at the absurdity of this belief, and yet no
hypothesis was ever taught more positively, or maintained more
tenaciously. It declared, in brief, that when substances burned, they
parted with a certain material called phlogiston. When, at length, its
advocates were asked to explain the fact, discovered by Dr. Priestly,
[5] that quicksilver, when burned, weighed more than before, they
were forced to put forward the ridiculous statement that phlogiston
possessed the property of “buoyancy” so that when it was contained
in a body its weight was lessened; which was as wise as the brilliant
supposition that a person can lift himself over a fence by tugging at
his boot straps. After a fierce struggle they were forced to confess
that they had placed “the cart before the horse.” The truth was
precisely opposite to their statement. Substances when they burn
take up something instead of giving it off. That something is oxygen,
and a body when burned, if it can be weighed, will be found to
weigh as much more as the added weight of the oxygen which has
united with it. Example: Iron-rust is iron, plus oxygen.
HYDRO-CARBONS.
All substances composed essentially of the elements, hydrogen
and carbon, would come under this designation. These would
include coal, wood, petroleum, the fats, resins, wax and many
others, with some of the gases, among which may be named light
and heavy carburetted hydrogen, CH₄ and C₂H₄ respectively.
PHOSPHORUS BURNING
IN OXYGEN.[8]
Coal is the key that unlocks for us the treasures of the iron ore. It
seizes upon the oxygen in the ore, and liberates the pure metal. By a
wonderful provision they often exist in the same mountain, side by
side. I have seen in Pennsylvania, running out of the same tunnel in
the hills, car loads of coal and iron ore.
Among the many advantages possessed by our own country is
our immense store of this precious hydro-carbon. With an area of
300,000,000 miles of territory, we have more than 200,000 square
miles of known coal producing area, or one in fifteen.
Great Britain has one-half of the coal fields of all Europe, but even
she has but one square mile of coal to twenty square miles of
territory. Beside, our coal seams are of great thickness, and lie
comparatively near the surface. In the far West, vast fields of
lignite[14] have been discovered, so that there seems no prospect of
our exhausting our fuel supply for ages to come.
The diamond is crystallized carbon, and can be burned, though
one would hardly care to be warmed by so costly a fire.
Cleopatra, in a freak of extravagance, dissolved a wonderful pearl,
but who could think of the wise queen of England using in so
wasteful a manner her Kohinoor.[15] Six of the great diamonds of the
world are called, by way of eminence, “The Paragons,” and a
romantic interest has been attached to this form of carbon among all
nations. In point of fact, however, the black diamonds of the coal pit
are more interesting, and of far greater value to mankind than these
glittering gems from Golconda,[16] Brazil and the Dark Continent.[17]
TEMPERANCE TEACHINGS OF
SCIENCE;
OR, THE POISON PROBLEM.
CHAPTER V.—PROHIBITION.
“Rugged or not, there is no other way.”—Luther.
The champions of temperance have to contend with two chief
adversaries—ignorance and organized crime. The well-organized
liquor league can boast of leaders whose want of principles is not
extenuated by want of information, and who deliberately scheme to
coin the misery of their fellowmen into dollars and cents. But the
machinations of such enemies of mankind would not have availed
them against the power of public opinion, if their cunning had not
found a potent ally in the ignorance, not of their victims only, but of
their passive opponents. We need the moral and intellectual support
of a larger class of our fellow-citizens, before we can hope to secure
the effectual aid of legal remedies, and in that direction the chief
obstacles to the progress of our cause have been the prevailing
misconceptions on the following points:
1. Competence of Legislative Power.—There can be no doubt that the
legislative authority even of civilized governments has been
frequently misapplied. The most competent exponents of political
economy agree that the state has no business to meddle in such
affairs as the fluctuation of market prices, the rate of interest, the
freedom of international traffic. On more than one occasion
European governments, having attempted to regulate the price of
bread-stuffs, etc., were taught the folly of such interference by
commercial dead-locks and the impossibility of procuring the
necessaries of life at the prescribed price, and were thus compelled
to remedy the mischief by repealing their enactments. Usury laws
tend to increase, instead of decreasing, the rate of interest, by
obliging the usurer to indemnify himself for the disadvantage of the
additional risk. The attempt to increase national revenues by
enforcing an artificial balance of trade has ever defeated its own
object. It is almost equally certain that compulsory charities do on
the whole more harm than good. On the other hand, there are no
more undoubtedly legitimate functions of government than the
suppression, and the, if possible, prevention, of crime, and the
enforcement of health laws; and it can be demonstrated by every
rule of logic and equity that the liquor traffic can be held amenable
in both respects. The favorite argument of our opponents is the
distinction of crime and vice. For the latter, they tell us, society has
no remedy, except in as much as the natural consequences (disease,
destitution, etc.) are apt to recoil on the person of the perpetrator;
the evil of intemperance therefore is beyond the reach of the law.
We may fully concede the premises without admitting the cogency of
the conclusion. The suspected possession or private use of
intoxicating liquors would hardly justify the issue of a search
warrant, but the penalties of the law can with full justice be directed
against the manufacturer or vender who seeks gain by tempting his
fellowmen to indulge in a poison infallibly injurious in any quantity,
and infallibly tending to the development of a body and soul
corrupting habit; they may with equal justice be directed against the
consumer, stupefied or brutalized by the effects of that poison. The
rumseller has no right to plead the consent of his victim. The
absence of violence or “malice prepense,”[1] is a plea that would
legalize some of the worst offenses against society. The peddler of
obscene literature poisons the souls of our children without a
shadow of ill-will against his individual customer. The gambler, the
lottery-shark, use no manner of force in the pursuit of their prey. By
what logic can we justify the interdiction of their industry and
condemn that of the liquor traffic? By the criterion of comparative
harmlessness? Have all the indecencies published since the invention
of printing occasioned the thousandth part of the misery caused by
the yearly and inevitable consequences of the poison vice? The
lottery player may lose or win, but the customer of the liquor vender
is doomed to loss as soon as he approaches the dram-shop. The
damage sustained by the habitual player may be confined to a loss
of money, while the habitual drunkard is sure to suffer in health,
character and reputation, as well as in purse. And shall we condone
the conduct of the befuddled drunkard on account of a temporary
suspense of conscious reason? That very dementation constitutes his
offense.
His actions may or may not result in actual mischief, but he has
put the decision of that event beyond his control. The man who
gallops headlong through crowded streets is punished for his
reckless disregard of other men’s safety, though the hoofs of his
horse may have failed to inflict any actual injury. A menagerie
keeper would be arrested, if not lynched, for turning a city into a
pandemonium by letting loose his bears and hyenas, and for the
same reason no man should be permitted to turn himself into a wild
beast.
“Virtue must come from within,” says Prof. Newman;[2] “to this
problem religion and morality must direct themselves. But vice may
come from without; to hinder this is the care of the statesman.” And
here, as elsewhere, prevention is better than cure. By obviating the
temptations of the dram-shop a progressive vice with an incalculable
train of mischievous consequences may be nipped in the bud. Penal
legislation is a sham if it takes cognizance of moral evils only after
they have passed the curable stage. “It is mere mockery,” says
Cardinal Manning,[3] “to ask us to put down drunkenness by moral
and religious means, when the legislature facilitates the
multiplication of the incitements to intemperance on every side. You
might as well call upon me as a captain of a ship and say: ‘Why
don’t you pump the water out when it is sinking,’ when you are
scuttling the ship in every direction. If you will cut off the supply of
temptation, I will be bound by the help of God to convert drunkards,
but until you have taken off this perpetual supply of intoxicating
drink we never can cultivate the fields. Let the legislature do its part
and we will answer for the rest.”
All civilized nations have recognized not only the right but the
duty of legislative authorities to adopt the most stringent measures
for the prevention of contagious disease; yet all epidemics taken
together have not caused half as much loss of life and health as the
plague of the poison vice.
2. Magnitude of the Evil.—Since health and freedom began to be
recognized as the primary conditions of human welfare, the
conviction is gaining ground that the principles of our legislative
system need a general revision. It was a step in the right direction
when the lawgivers of the Middle Ages began to realize the truth
that the liberty of individual action should be sacrificed only to
urgent consideration of public welfare, but the modified theories on
the comparative importance of these considerations have
inaugurated a still more important reform. Penal codes gradually
ceased to enforce ceremonies and abstruse dogmas and to ignore
monstrous municipal and sanitary abuses. The time has passed
when legislators raged with extreme penalties against the
propagandists of speculative theories and ignored the propagation of
slum diseases, yet, after all, there is still a lingering belief in the
minds of many contemporaries that intemperance, as a physical evil,
a “mere dietetic excess,” does not justify the invasion of personal
liberty. They would consent to restrict the freedom of thought and
speech rather than the license of the rum-dealer, yet the tendency of
a progressive advance in public opinion promises the advent of a
time when that license will appear the chief anomaly of the present
age. The numberless minute prescriptions and interdicts of our law
books and their silence on the crime of the liquor traffic will make it
difficult for coming ages to comprehend the intellectual status of a
generation that could wage such uncompromising war against
microscopic gnats and consent to gratify the greed of a monstrous
vampire.
3. Self-correcting Abuses.—Modern physicians admit that various
forms of disease which were formerly treated with drastic drugs can
be safely trusted to the healing agencies of nature. Many social evils,
too, tend to work out their own cure. High markets encourage
competition and have led to a reduction of prices. Luxury leads to
enforced economy by reducing the resources of the spendthrift.
Dishonest tradesmen lose custom, and a German government that
used to fine editors for publishing unverified rumors might have left
it to the subscribers to withdraw their patronage from a purveyor of
unreliable news. But there are certain causes of disease that
demand the interference of art. Poisons, especially, require artificial
antidotes. If a child has mistaken arsenic for sugar, its life commonly
depends on the timely arrival of a physician. The organism may rid
itself of a surfeit, but is unable to eliminate the virus of a skin
disease. Alcoholism belongs to the same class of disorders. We need
not legislate against corsets; the absurdities of fashion change and
vanish like fleeting clouds, and their votaries may welcome the
change; but drunkards would remain slaves of their vice though the
verdict of public opinion should have made dram-drinking extremely
unfashionable. The morbid passion transmitted from sire to son, and
strengthened by years of indulgence, would defy all moral restraints
and yield only to the practical impossibility to obtain the object of its
desire.
“A number of years ago,” says Dr. Isaac Jennings, “I was called to
the shipyard in Derby, to see John B., a man about thirty years of
age, of naturally stout, robust constitution, who had fallen from a
scaffold in a fit, head first upon a spike below. In my visit to dress
the wounded head, I spoke to him of the folly and danger of
continuing to indulge his habit of drinking, and obtained from him a
promise that he would abandon it. Not long after I learned that he
was drinking again, and reminded him of his promise. His excuse
was, that it would not do for him to abandon the practice of drinking
suddenly. A few weeks after this he called at my office and
requested me to bleed him, or do something to prevent a fit, for he
felt much as he did a short time before having the last fit. I said to
him, ‘John, sit down here with me and let us consider your case a
little.’ I drew two pictures and held before him; one presented a wife
and three little children with a circle of friends made happy and
himself respectable and useful in society; the other, a wretched
family, and himself mouldering in a drunkard’s grave; and appealed
to him to decide which should prove to be the true picture. The poor
fellow burst into tears and wept like a child. When he had recovered
himself from sobbing so that he could speak he said: ‘Doctor, to tell
you the truth, it is not that I am afraid of the consequences of
stopping suddenly that I do not give up drinking. I can not do it. I
have tried and tried again, but it is all in vain. Sometimes I have
gone a number of weeks without drinking, and I flattered myself
that the temptation was gone, but it returned, and now if there was
a spot on earth where men lived and could not get spirits, and I
could get there, I would start in a minute.’ I thought I had
understood something of the difficulties of hard drinkers before, but
this gave me a new impression of the matter, and most solemnly did
I charge myself to do what I could to make a spot on earth where
men could live and couldn’t get spirits.”
4. Lesser Evils.—Even in a stricter form than any rational friend of
temperance would desire its enforcement, prohibition would not
involve any consequences that could possibly make the cure a
greater evil than the disease. The predicted aching void resulting
from the expurgation of beer-tunnels could be filled by healthier
means of recreation. The grief of the superseded poison-mongers
would not outweigh the mountain-load of misery and woe which the
abolishment of their cursed trade would lift from the shoulders of
the nation. When the state of Iowa declared for prohibition the
opponents of that amendment bemoaned the loss entailed by the
departure of “so many industrious and respectable citizens,” i. e.,
from the exodus of the rumsellers! We might just as well be asked to
bewail the doom of the Thugs[4] as the subversion of a prosperous
industry. We might as well be requested to sympathize with the
respectable bloodhound-trainers and knout-manufacturers whom the
abolition of slavery threw out of employment. The liquor dealer has
no right to complain about the rigor of a law that permits him to
depart with the spoils of such a trade. We are told that the mere
rumor of Maine laws has deterred many foreigners from making their
homes with us; that the Russian peasants decline to come without
their brewers and distillers, and that by general prohibition we would
risk to reduce our immigration from every country of northern
Europe. We must take that risk, and let Muscovites rot in the bogs of
the Volga if they can not accept our hospitality without turning our
bread corn into poison. Our utilitarian friends would hardly persuade
us to legalize cannibalism in order to encourage a larger immigration
of Fiji islanders. The absence of such guests might not prove an
unqualified evil. I shall not insult the intelligence of my readers by
repeating the drivel of the wretches who would weigh the reduction
of revenues against the happiness of a hell-delivered nation, and I
will only mention the reply of a British financier who estimates that
the increase of national prosperity would offset that reduction in less
than five years.
5. Efficacy of Prohibition.—Will prohibition prevent the use of
intoxicating liquor? Not wholly, but it will answer its purpose. It will
banish distilleries to secret mountain glens and hidden cellars. It will
drive the man-traps of the poison-monger from the public streets. It
will save our boys from a hundred temptations; it will help
thousands of reformed drunkards to keep their pledge; it will restore
peace and plenty to many hundred thousand homes. More than a
century ago the philosopher Leibnitz[5] maintained that the plenary
suppression of the liquor traffic would be the most effectual means
for reforming the moral status of civilized nations, and experience
has since fully demonstrated the correctness of that opinion. A
memorandum endorsed by a large number of statistical vouchers
describes the effect of prohibition in Sweden: “The nation rose and
fell, grew prosperous and happy, or miserable and degraded, as its
rulers and law-makers restrained or permitted the manufacture and
sale of that which all along the track of its history has seemed to be
the nation’s greatest curse.” … “The vigorously maintained
prohibition against spirits in 1753-1756, and again in 1772-1775,
proved the enormous benefits effected in moral, economical, and
other respects, by abstinence from intoxicating spirits.” … “This it is
which has so helped Sweden to emerge from moral and material
prostration, and explains the existence of such general indications in
that country of comfort and independence among all classes.”
From the Edinburgh Review for January, 1873, we learn that in
eighty-nine private estates in England and Scotland, “the drink traffic
has been altogether suppressed, with the happiest social results.
The late Lord Palmerston[6] suppressed the beer shops in Romsey as
the leases fell in. We know an estate which stretches for miles along
the romantic shore of Loch Fyne,[7] where no whiskey is allowed to
be sold. The peasants and fishermen are flourishing. They have all
their money in the bank, and they obtain higher wages than their
neighbors when they go to sea”—a proof that a small oasis of
temperance can maintain its prosperity in the midst of poison-
blighted communities.
Here and there the wiles of the poison-mongers will undoubtedly
succeed in evading the law, but their power for mischief will be
diminished as that of the gambling-hell was diminished in Homburg
and Baden,[8] where temptation was removed out of the track of the
uninitiated till the host of victims dwindled away for want of recruits.
Not the promptings of an innate passion, but the charm of artificial
allurements is the gate by which ninety-nine out of a hundred
drunkards have entered the road to ruin. It would be an
understatement to say that the temptation of minors will be reduced
a hundred fold wherever the total amount of sales has been reduced
as much as five fold—a result which has been far exceeded, even
under the present imperfect system of legal control. “In the course
of my duty as an Internal Revenue officer,” says Superintendent
Hamlin of Bangor, “I have become thoroughly acquainted with the
state and extent of the liquor traffic in Maine, and I have no
hesitation in saying that the beer trade is not more than one per
cent. of what I remember it to have been, and the trade in distilled
liquors is not more than ten per cent. of what it was formerly.” “I
think I am justified in saying,” reports the Attorney-General, “that
there is not an open bar for the sale of intoxicating liquor in this
county” (Androscoggin, including the manufacturing district of
Lewiston—once a very hotbed of the rum traffic). “In the city of
Biddeford, a manufacturing place of 11,000 inhabitants, for a month
at a time not a single arrest for drunkenness has been made or
become necessary.” And from Augusta (the capital of the state): “If
we were to say that the quantity of liquor sold here is not one-tenth
as large as formerly, we think it would be within the truth; and the
favorable effects of the change upon all the interests of the state are
plainly seen everywhere.”
“It is perhaps not necessary,” says the Boston Globe, of July 29,
1875, “to dwell on the evils of intemperance, and yet people seldom
think how great a proportion of these might be prevented by driving
the iniquity into its hiding places, and preventing it from coming
forth to lure its victims from among the unwary and comparatively
guileless. Few young men who are worth saving, or are likely to be
saved to decency and virtue, would seek it out if it were kept from
sight. But when it comes forth in gay and alluring colors, it draws a
procession of our youth into a path that has an awful termination.
Nor does the evil which springs from an open toleration of the way
in which this vice carries on its traffic of destruction fall only on men.
A sad proportion of its victims is made up from shop girls and
abandoned women who are not so infatuated at the start that they
would plunge into a life of infamy if its temptations were strictly
under the ban, and kept widely separated from the world of
decency. But it intruded itself upon them. Its temptations and
opportunities are before their eyes, and the way is made easy for
their feet to go down to death.”
“To what good is it,” says Lord Brougham,[9] “that the legislature
should pass laws to punish crime, or that their lordships should
occupy themselves in trying to improve the morals of the people by
giving them education? What could be the use of sowing a little seed
here and plucking up a weed there, if these beer shops are to be
continued to sow the seeds of immorality broadcast over the land,
germinating the most frightful produce that ever has been allowed to
grow up in a civilized country, and, I am ashamed to add, under the
fostering care of Parliament.”
The prohibition of the poison traffic has become the urgent duty
of every legislator, the foremost aim of every moral reformer. The
verdict of the most eminent statesmen, physicians, clergymen,
patriots and philanthropists, is unanimous on that point. We lack
energy, not competence, nor the sanction of a higher authority, to
gain the votes of the masses.
“We can prove the success of prohibition by the experience of our
neighboring state,” writes Dr. Herbert Buchanan, of Portsmouth, New
Hampshire; “all the vicious elements of society are arraigned against
us, but I have no fear of the event if we do not cease to agitate the
subject.”
Agitation, a ceaseless appeal to the common sense and
conscience of our fellowmen can, indeed, not fail to be crowned with
ultimate success. The struggle with vice, with ignorance and mean
selfishness may continue, but it will be our own fault if our
adversaries can support their opposition by a single valid argument,
and the battle will be more than half won if a majority of our fellow-
citizens have to admit that we contend no longer for a favor, but for
an evident right.
STUDIES IN KITCHEN SCIENCE AND
ART.