0

I have to choose between a JPA or JDBC (including Spring-JDBC) based solution for my project.

The context is a Java application doing read only access on a fixed data model.

The data model is event-oriented : for instance, every 5 seconds, a car position and state will be recorded.

My first feeling is that JDBC fits more our needs, but i'm new to JPA. What solution is adapted according to you and why ?

Duplicate update: my biggest concern is about the context (read-only with fixed data model) to know if JPA is fit to my project or if it's too complex/not adapted for my project

DenisB
  • 165
  • 1
  • 1
  • 11
  • Possible duplicate of [Hibernate or JPA or JDBC or?](http://stackoverflow.com/questions/2560500/hibernate-or-jpa-or-jdbc-or) – Tobias Liefke Oct 06 '15 at 20:59

3 Answers3

2

Why reinvent the wheel? ORM products have been out there for decades and standardized with JPA, so it depends on what you are going to do. Unless you have absolutely no chance this project will be expanded upon or reused in anyway, why make it more complicated by building your own framework?

Any ORM gives you central control to tweak performance options and even state what SQL you want to execute, without having to deal with connection pooling, statement creation, caching etc. I'd let it write the queries for you as it lets you to run against different databases as needed, and even change the database model undeath without requiring major application rewrites.

Chris
  • 20,138
  • 2
  • 29
  • 43
  • My wondering is about the complexity we add compared to the utility we get from an ORM in our context. Can it easily fit to any data model for instance ? – DenisB Oct 06 '15 at 20:34
0

If you have to do read actions you can use JDBC since you can easily get the data you want with it. JPA is good, but I would prefer JDBC.

cdaiga
  • 4,861
  • 3
  • 22
  • 42
0

If you know you'll only run one or several SELECT statements, definitely go with JDBC.

JPA is intended to be used in more complexes projects, when you want to be able to manipulate database elements as java objects. Of course, for this convenience you pay with performance... JPA has its overhead.

Goodluck!

Shay
  • 92
  • 1
  • 4