Spring ORM (hibernate) vs hibernate

I have used hibernate in my java project where I was using Spring MVC.

I avoided Spring HIBERNATE because it seemed to be very much related to my code. Now, even if I switch the application to struts, my service layer will work fine (because I was using kernel hibernation, this is not the one that Spring provides).

I would like an experienced developer to answer this:

What is the reason for using Spring hibernation? I know it provides a number of features, but there is a tradeoff since it really makes your code tightly coupled, you cannot reuse services anywhere else as they will work based on the Spring hibernate api

+3


source to share


3 answers


Spring, which has 7 different modules, each of which is independent, you can use any of them or several

  • Core container
  • Spring context
  • Spring AOP
  • Spring DAO
  • Spring ORM
  • Spring Web Module
  • Spring MVC Framework


if you want to know about ORM integration, trust me it doesn't make a hard link to your service level.

you can use strut mvc at the same time at service layer spring -orm + hibernate no hard linking, more spring provides mgt transaction. hibernatetemplate, you don't need to worry about mgt session and transactions and of course ease of integration and customization.

+4


source


According to my experience, Spring-Hibernate provides:

  • Template to simplify configuration
  • The persistence engine can be used as a dependency, so you can change it whenever you want without changing the JPA annotations in the model classes.
  • It should be much more efficient for managing XA transactions.


And nothing else...

+1


source


Well tricky question, I could answer it with another question:

What is the reason for using hibernate mode? I know it provides a number of features, but there is a trade-off since it really makes your code tightly coupled, you cannot reuse services anywhere else as they will work based on the hibernate api.

Why not use straight JDBC and SQL?

To be more productive in the matter: the choice of structure always comes with a compromise: in combination with the framework.

Thus, either the features provided by the infrastructure must pay for the trade-off or not.

0


source







All Articles