Java Frameworks War: Spring and Hibernate

后端 未结 18 1837
北海茫月
北海茫月 2020-12-23 12:08

My developers are waging a civil war. In one camp, they\'ve embraced Hibernate and Spring. In the other camp, they\'ve denounced frameworks - they\'re considering Hibernate

相关标签:
18条回答
  • 2020-12-23 12:24

    Spring and Hibernate are frameworks that are tricky to master. It may not be a good idea to use them in projects with tight deadlines while you're still trying to figure out the frameworks.

    The benefits of the frameworks is basically to try to provide a platform to allow for consistent codes to be products. From experience, you'd be well advised to have developers experienced with the frameworks setting in place best practices.

    Depending on the design of your application and/or database, there are also quirks that you'll need to circumvent to ensure that the frameworks do not hinder performance.

    0 讨论(0)
  • 2020-12-23 12:26

    Lazy loading is the big gotcha in MVC applications that use Hibernate for their persistence framework. You load the object in the controller and pass it to the JSP view. Some or all of the members of the class are proxied and everything blows up because you Hibernate session was closed when the controller completed.

    You will need to read the Open Session in View article to understand the problem and get a solution. If you are using Spring the this blog article describes the Spring solution to the open session in view issue.

    0 讨论(0)
  • 2020-12-23 12:26

    I find it really helps to use well-known frameworks such as Hibernate because it fits your code into a specific mold, or a way of thinking. Meaning, since you're using Hibernate, you write code a certain way, and most if not all developers who know Hibernate will be able to follow your line of thinking quite easily.

    There's a downside to this, of course. Before you become a hot shot Hibernate developer, you're going to find that you're trying to fit a square into a circular hole. You KNOW what you want to do, and how you were supposed to do it before Hibernate came into the picture, but finding the Hibernate way of doing it may take... quite a bit of time.

    Still, for companies that frequently hire consultants (who need to understand a lot of source code in a short amount of time) or where the developers sign on and quit frequently, or where you just don't want to bet that your key developers will stay forever and never change jobs -- Hibernate and other standard frameworks are a pretty good idea I think.

    /Ace

    0 讨论(0)
  • 2020-12-23 12:28

    Spring and Hibernate definitely make life easier. Getting started with them might be a little time-consuming at the beginning, but you'll certainly benefit from it later. Now the XML is being replaced by annotations, you don't need to type hundreds of lines of XML either.

    You may want to consider AppFuse to reduce your learning-curve: generate an application, study and adapt it, and off you go.

    0 讨论(0)
  • 2020-12-23 12:30

    They've denounced frameworks?

    That's nuts. If you don't use an off-the-shelf framework, then you create your own. It's still a framework.

    0 讨论(0)
  • 2020-12-23 12:32

    I haven't worked much with Java but I did work in large groups of Java developers. The impression I've got was that Spring is OK. But everybody was upset at Hibernate. Half the team if asked "If you could change one thing, what would you change?" and they'd say "Get rid of Hibernate.". When I started to learn Hibernate it struck me at amazingly complex, but I didn't learn enough (thankfully I've moved along) to know if the complexity was justified or not (maybe it was require to solve some complex problems).

    The team got rid of Spring in favor of Guice, but that was more like a political change, at least from my point of view and other developers I've talked to.

    0 讨论(0)
提交回复
热议问题