0

I have a Oracle procedure with some 2000 lines with lots of inserts , updates , joins , selects , lot of "insert into select from with multiple and complex joins" I wanted to convert it into java batch. I have multiple options with me to get this done.

  1. Plain JDBC
  2. Spring JDBC template
  3. Hibernate
  4. Spring JPA

I am able to convert the procedure to JAVA using simple plain JDBC and it is working perfectly fine. I optimized the code and it is looking okay. But I would like to consider other alternatives maybe like using Hibernate or JDBC template. Just need suggestions , comments on re-writing it on hibernate. Do you suggest to let it be in plain JDBC or pick any ORM framework ? Advantages or Disadvantages of picking Hibernate or JDBCtemplate? Is Hibernate good for complex joins and "insert into select from"??

Stunner
  • 961
  • 2
  • 19
  • 39

1 Answers1

0

There is no yes/no answers for these questions. Would like to suggest this link for your analysis: Spring-JDBC-JPA vs Hibernate

This is about analyzing whether the relational model can be represented in an OO model if you are using an ORM like Hibernate without inducing complexity. If the relational model is complex would like to suggest to use Spring JDBC with native SQL. Spring JDBC handles the boiler-plate issues like opening/closing DB connections,exception handling etc., which needs to be handled by you in the plain old JDBC world.

If you need control on the SQL, since you have mentioned complex joins would be better off writing native SQL. If you are really sure the relational model is properly translated to a robust OO model and you are confident with the SQLs generated by hibernate are optimized based on your foreign-key mappings, then go for hibernate. Of course, there are many convenient features in Hibernate which would not be available in other ORMs. Again, it's about where you want to shift the control, to the developer or the framework. These are my humble suggestions.

Please correct if I have missed out anything.

I haven't worked on JPA so may be other developer experts can comment on that.

VijayC
  • 79
  • 8
  • apart from exceptoin handling , DB connection autoclose does spring jdbctemplate has any advantage.... please eloborate "etc" – Stunner Mar 19 '20 at 03:46
  • It is not about the advantages/disadvantages of a framework but how it suits for the problem you are solving. In hibernate, learning curve is steep,you must really know the entities are designed carefully and you will reap the benefits only if used effectively.This is not a disadvantage of Hibernate but the development process. FYR: https://stackoverflow.com/questions/11791145/spring-jdbctemplate-vs-hibernate-in-terms-of-performance – VijayC Mar 19 '20 at 07:42