Spring Hibernate Vs jdbc template vs spring orm [closed]

情到浓时终转凉″ 提交于 2019-11-27 20:36:07

问题


We have a project with MySQL database and Spring as the framework. I am very new to Spring and looking to implement the database access layer and found that there are several options available, like

  • Using Spring + Hibernate
  • Using Spring JDBC Template
  • Using Spring ORM Module

I have gone through the various posts in stackoverflow and did a bit of research on the web, but every question had different answers supporting different options. Also, I did see a mention about Spring JDBC template not being recommended now.

The application might have approximately 1000 transactions per hour and have 60% reads and 40% writes, approximately.

Can anyone help me in finding an answer as to which of the 3 options is suitable and why ? Or, if you can point me to some resources, that would be highly appreciated as well.


回答1:


Hibernate is just one of the many ORM solutions that Spring supports; others are listed here.

You might choose ORM if all of the following were true:

  1. You had a solid object model to map relational data to.
  2. You liked the SQL generated for you by the ORM layer.
  3. Your schema conformed nicely to the requirements of the ORM solution.
  4. You weren't using a lot of stored procedures.
  5. You didn't think you could optimize SQL better than the ORM could.

If any of those aren't true, maybe an ORM isn't for you.

Spring JDBC template is light and simple. I would bet that it could accomodate your stated requirements. I'd recommend going with that until you found out that your requirements drove you to ORM. If you follow the typical Spring idiom and create an interface-based persistence layer, this will mean injecting one implementation instead of another.



来源:https://stackoverflow.com/questions/11850521/spring-hibernate-vs-jdbc-template-vs-spring-orm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!