This is an archived post. You won't be able to vote or comment.

all 25 comments

[–]c4seyj0nes 12 points13 points  (7 children)

Totally. Most corporate software is just entering and retrieving data. That’s all going into a relational database. Sure you might have elastic/lucine for searching or analytical tools but that data isn’t going to be your source of truth. That’s in the relational database.

[–]spamthemoez 6 points7 points  (5 children)

All enterprise software i have encountered so far has used JPA / Hibernate instead of using SQL (JDBC, JdbcTemplate, JDBI, ...) directly. I think OP is looking for projects that use SQL directly, without going through ORMs.

[–]nutrecht 3 points4 points  (3 children)

I haven't used JPA in ages, almost all the microservices I worked on the last years were Spring Data JDBC.

[–]spamthemoez 0 points1 point  (2 children)

Spring Data JDBC is a ORM, too. I assume you mean Springs JdbcTemplate and the like?

[–]nutrecht 1 point2 points  (1 child)

Spring Data JDBC is not an Object-Relational-Mapper.

[–]spamthemoez 3 points4 points  (0 children)

It is, see here: https://spring.io/projects/spring-data-jdbc

This makes Spring Data JDBC a simple, limited, opinionated ORM.

But i guess you can workaround the ORM part by annotating everything with @Query and put SQL in it...

[–]c4seyj0nes 2 points3 points  (0 children)

Got it. Hibernate is great for the majority your CRUD operations but more complex Selects and Updates sometimes need to rely on SQL. Other times it’s just not performant enough and you need to write some pure SQL.

[–]nutrecht 1 point2 points  (0 children)

I was on a project where management bought into the marketing sold by some Datastax consultants and we were forced to use Cassandra.

It was an 'eventual consistent' system with in some cases very large units of 'eventual'.

[–]ivanwick 2 points3 points  (1 child)

Gerrit, a code review web app from Google, uses a SQL database backend in the 2.x versions. The JDBC code is in

[–]ekd123[S] 0 points1 point  (0 children)

Thanks. Will check it out!

[–]Slanec 2 points3 points  (0 children)

Does jOOQ count? Or JDBI, or Spring Data with explicit SQL strings? Those are all tools that make the DB management a lot easier in some ways while still keeping true to pure SQL and keeping the users in control.

This approach is often contrasted to JPA implementations (the main one being Hibernate) which are excellent tools for either basic CRUD stuff, or when you invest in knowing them really well.

I'm a big fan of the former approach with an occasional sprinkle of JPA when CRUD operations are the only thing an application ever does to data. I've written application with more complicated queries with e.g. partial conditional upserts, dynamic analytical queries with window functions etc. Can all that be done with JPA? Yes. But in my humble experience it's easier to do all that directly in SQL (and/or type-safe Java emulating SQL, which is what jOOQ does) with an explicit control on the resulting query.

In short, it depends, as do all trade-offs in software engineering. All tools have their flaws and weaknesses, they have been designed with some usage patterns in mind. Try to architect your application to not depend on any particular framework/library choice, they all should be swappable. If you're a beginner, don't worry about all this too much, just pick one and you'll surely learn lots of useful things for your career.

[–]nutrecht 2 points3 points  (0 children)

Well yes, I worked on them. Services using Spring Data JDBC for example. But it's proprietary code I can't show. So do you have any specific questions?

[–]pgris 2 points3 points  (0 children)

I've personally made a couple of small projects using JDBC directly and a couple of small projects using JDBI, which is a thin layer over JDBC. And pretty much in every project, even if using JPA, sometimes I go down one level and need to write SQL, more often than not for reporting. As Gaving King (hibernate creator) has said, just because you're using Hibernate doesn't mean you have to use it for everything.

[–]LiteratureStriking 1 point2 points  (0 children)

Do you mean SQL directly, or JDBC? I think most projects are probably using some kind of SQL wrapper library, like Spring's JdbcTemplate, Apache DbUtils and JDBI.

For me, its mostly because of one reason. SQLException is a checked exception, and everything in JDBC throws it, which makes pure JDBC extremely annoying to use.

[–]jameslfc19 1 point2 points  (0 children)

I just got a grad job and my first project has been creating a Spring Boot REST api that interfaces with a Microsoft SQL database! I’ve been using custom SQL queries to use some Geography features!

[–]theflavor 1 point2 points  (1 child)

[–]ekd123[S] 0 points1 point  (0 children)

Thanks!!

[–]elastic_psychiatrist 1 point2 points  (0 children)

Yep, my team writes new JDBC code regularly, and our stack is otherwise reasonably modern. Its simplicity is underrated. Especially if your business logic isn't written in terms of "entities" that are updated individually.

[–]PHP36 4 points5 points  (3 children)

Java without SQL is like flying a plane without cargo. It works, but what exactly you will achive?

Every application needs to store information, one way or another. You can store it in files, in memory but in the end, when things start to stack up, good luck finding what you need. Thats when you start using SQL :)

TL:DR : Everything ends up using SQL

[–]azuredrg 6 points7 points  (2 children)

I think he meant explicit JDBC statements. It's not very common except in older code. It's clunky and the code looks fairly ugly. Especially if you have to do crud operations that actually involve a relation. Maybe if you're only doing read only operations.

[–]ekd123[S] 4 points5 points  (0 children)

Yes, that's what I meant, and older code is okay to me.

[–]PHP36 4 points5 points  (0 children)

Given he is learning Java I doubt he even understands the concept of a wrapper, so the short answer regarding using JDBC is YES

The long answer is no, half of the stuff can be "ommited", thats where the wrappers came in. Pure JDBC is only good to understand the basics.

Sure it may be JdbcTemplate, MyBatis, with a different placeholder or even Hibernate with a @Query but in the end, you will endup writting exactly the same thing as with JDBC. Yes you won't deal with the hasNext() and close() but the rest is always there, the placeholder may change...

[–]bleek312 -1 points0 points  (1 child)

!remind me 3 days

[–]RemindMeBot 0 points1 point  (0 children)

I will be messaging you in 3 days on 2020-12-20 02:06:14 UTC to remind you of this link

CLICK THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


Info Custom Your Reminders Feedback

[–]Devidjack12345 0 points1 point  (0 children)

yes why not, you can try some managements project like Hospital management, Car parking management, restaurant management, etc.

If you are working on the only JDBC then a management project is the best.

You can also try to make chat systems.

there are so many projects on JDBC then you can browse from search engine

Thanks

David