Win a copy of Machine Learning with R: Expert techniques for predictive modeling this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Hibernate or JdbcTemplate

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need a piece of advice. I'm going to write a platform for selling products. On the client side I need to have rich visual effects and a scripting language - these are the requirements - so probably the client side would be written in pure JavaScript, CSS and HTML. The server side would be implemented in Spring with many REST services. What I doubt is to use JdbcTemplate or Hibernate to implement DAO.

JdbcTemplate:
+ native SQL code
+/- RowMappers to map results to objects
+ flexible enough to fit my requirements

Hibernate:
+ no need to use RowMappers
- what about compound data base schemas?
- need to generate entities every time db changes

The main problem with Hibernate is the need to map entities to JSON (or XML maybe). As a result entities "are leaving" the persistent context which may cause a lot of problems (I've already faced then when using GWT, e.g. hibernate session) that may be very harmful and troublesome.

So the question is to use Hibernate and spend a lot of time solving the mentioned problems or to use JDBC which is old but I guess it better fits to requirements. Or maybe another solution that I don't know currently.

Any help, clues would be much appreciated.
 
Ranch Hand
Posts: 218
Hibernate Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should use a ORM solution. Since you are building a platform for selling products you will have decent number of entities. Hibernate will improve productivity & help bridge the paradigm mismatch between RDBMS & object oriented languages. Also it will make application maintainable. All this will be possible if you have decent understanding of ORM which will help you avoid common pitfalls that people encounter while using ORM.

In terms of issues due to non-availability of persistence context, there are well known patterns/approaches to address this type of issues.
 
Maciej Opala
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the response. I much appreciate it.

Rishi Shehrawat wrote:In terms of issues due to non-availability of persistence context, there are well known patterns/approaches to address this type of issues.


Could You please say something more on the topic?
 
ranger
Posts: 17344
11
Mac IntelliJ IDE Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An ORM tool will give you lots of benefits, for JSON, you actually could use Spring REST Web Service on top of Spring MVC and you only will need the Jackson library jar file.

One question about your site, is it a must that you build it from scratch? I mean there are lots of e-commerce products/websites out there to do all the hard work for you. I personally have one myself at a website called Big Commerce, where I set it up with a template, added my products and site all done, no coding.

I also recommend looking at something like Spring Data JPA if you do choose Hibernate, it will help simplify your DAO/Repositories.

In terms of patterns, anytime you have a website where data gets sent to the client, once it is on the client, you aren't managing it, so whether you use JPA/Hibernate or Jdbc code you will still have to know if you are updating, deleting, or inserting data. But that is what is nice about REST is that it fits the CRUD types well with POST, PUT, GET, and DELETE.

Mark

 
Maciej Opala
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the comprehensive response.

The website will be build from scratch, that's not my decision but my boss and accroding to the requirements I'm not sure if there's ready to use product for such case. I won't be a typical web store :]

Will investigate Spring solutions.
 
A day job? In an office? My worst nightmare! Comfort me tiny ad!
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!