Jinq provides developers an easy and natural way to write database queries in Java. You can treat database data like normal Java objects stored in collections. You can iterate over them and filter them using normal Java commands, and all your code will be automatically translated into optimized database queries. Finally, LINQ-style queries are available for Java!
With Jinq, you can write database queries using a simple, natural Java syntax. Using Java 8's new support for functional programming, you can filter and transform data in a database using the same code you would use for normal Java data.
For example, below is some Java code that uses Jinq to get a list of all the customers named "Alice" from a database.
database.customerStream().where( customer -> customer.getName().equals("Alice"));
When the code is executed in Java, Jinq will automatically convert the code into SQL queries that a database can understand.
PreparedStatement s = con.prepareStatement("SELECT * " + "FROM Customer C " + "WHERE C.Name = ? "); s.setString(1, "Alice"); ResultSet rs = s.executeQuery();
Existing database queries are written inside strings. To check for errors, you must start up a database and run the queries. This slows development and leads to more bugs.
Jinq queries are normal Java code, and the Java compiler will catch bugs early, speeding your development. Since queries are written as Java code, common SQL injection security problems are impossible.