Skip to content

Commit 229a967

Browse files
committed
Java/Jinq: Add README as a stub
1 parent 538e160 commit 229a967

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

by-language/java-jinq/README.rst

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
.. highlight:: sh
2+
3+
############################################################
4+
Java Jinq demo application for CrateDB using PostgreSQL JDBC
5+
############################################################
6+
7+
8+
Jinq - Simple Natural Queries with Java.
9+
10+
11+
*****
12+
About
13+
*****
14+
15+
In a nutshell
16+
=============
17+
18+
A demo application using `CrateDB`_ with `Jinq`_ and the `PostgreSQL
19+
JDBC driver`_.
20+
21+
It is intended as a basic example to demonstrate what works, and what not.
22+
Currently, it is only a stub. Contributions are welcome.
23+
24+
Introduction
25+
============
26+
27+
`Jinq`_ and `jOOQ`_ are in a similar area like `LINQ`_. We've picked up and
28+
summarized some bits from blog posts and interviews by Dr. Ming-Yee Iu and
29+
Lukas Eder, the main authors of Jinq and jOOQ.
30+
31+
Firstly, you may enjoy the guest post by Dr. Ming-Yee Iu `Java 8 Will
32+
Revolutionize Database Access`_, which outlines how adding functional-support
33+
to the Java language version 8 made a difference while aiming to write database
34+
inquiries more fluently at that time (2014).
35+
36+
Ever since Erik Meijer has introduced LINQ to the .NET ecosystem, us Java
37+
folks have been wondering whether we could have the same.
38+
39+
Two years later, Dr. Ming-Yee Iu gives an `insight into Language Integrated
40+
Querying`_ at the `jOOQ Tuesdays series`_.
41+
42+
LINQ makes a lot of sense for the C# ecosystem, but I think it is totally
43+
inappropriate for Java.
44+
45+
Fortunately, Java programmers can use libraries such as Jinq and jOOQ
46+
instead, which provide most of the benefits of LINQ but don’t require tight
47+
language integration like LINQ.
48+
49+
50+
********
51+
Synopsis
52+
********
53+
54+
The idea of Jinq is to write database queries using a simple, natural Java
55+
syntax based on the functional programming support added with Java 8. Accessing
56+
a database table using the Jinq API looks like this:
57+
58+
.. code-block:: java
59+
60+
// Fetch records, with filtering and sorting, result iteration and printing.
61+
customers()
62+
.where(c -> c.getCountry().equals("UK"))
63+
.sortedDescendingBy(c -> c.getSalary())
64+
.forEach(c -> out.println(c.getName() + " " + c.getSalary()));
65+
66+
A few other concise `Jinq code examples`_ can be discovered at the Jinq code
67+
base.
68+
69+
70+
*******
71+
Details
72+
*******
73+
74+
From the documentation at http://www.jinq.org/, about what Jinq actually is,
75+
and does.
76+
77+
Jinq provides developers an easy and natural way to write database queries
78+
in Java. You can treat database data like normal Java objects stored in
79+
collections. You can iterate over them and filter them using normal Java
80+
commands, and all your code will be automatically translated into optimized
81+
database queries. Finally, LINQ-style queries are available for Java!
82+
83+
With Jinq, you can write database queries using a simple, natural Java
84+
syntax. Using Java 8's new support for functional programming, you can
85+
filter and transform data in a database using the same code you would use
86+
for normal Java data.
87+
88+
89+
.. _CrateDB: https://github.com/crate/crate
90+
.. _Jinq code examples: https://github.com/my2iu/Jinq/blob/main/sample/src/com/example/jinq/sample/SampleMain.java
91+
.. _Insight into Language Integrated Querying: https://blog.jooq.org/jooq-tuesdays-ming-yee-iu-gives-insight-into-language-integrated-querying/
92+
.. _Java 8 Will Revolutionize Database Access: https://blog.jooq.org/java-8-friday-java-8-will-revolutionize-database-access/
93+
.. _Jinq: https://github.com/my2iu/Jinq
94+
.. _jOOQ: https://github.com/jOOQ/jOOQ
95+
.. _jOOQ Tuesdays series: https://www.jooq.org/tuesdays
96+
.. _LINQ: https://en.wikipedia.org/wiki/Language_Integrated_Query
97+
.. _PostgreSQL JDBC Driver: https://github.com/pgjdbc/pgjdbc

0 commit comments

Comments
 (0)