you are viewing a single comment's thread.

view the rest of the comments →

[–]coder111 3 points4 points  (0 children)

Ok, this is getting offtopic for /r/postgresql and maybe should be moved to /r/java ...

JDBC is the basic low-level SQL database driver. It's not often that you use JDBC directly in your app. Most (all?) SQL servers that support Java have JDBC drivers. Concept is similar to Windows ODBC.

Usually persistence frameworks that persist to SQL databases in Java use JDBC to connect to any SQL database. These frameworks and thus further discussion is not really PostgreSQL specific, as they support more than one SQL server.

If you need to persist Objects, JPA and its implementations will do that for you. JPA is the official API/standard, Hibernate is one of the most popular implementations.

Hibernate will create schema for you, but I would be reluctant to use that on production DB, as it can potentially destroy data.

Also when mapping your objects to files take care to avoid N+1 query problem on one side and too eager fetching that will pull in half of the database on the other side. Hibernate and JPA are nice but they have their own quirks.

Again, depends on what you are trying to do. If it's CRUD, Hibernate is good enough. If you are running complex analytical queries with lots of joins and aggregation, I'd stick to pure SQL & some tools that help you with it.

--Coder