Skip to main content

The Heavyweight Champions are... Springframework and Hibernate?

There are a lot of argumentations exist trying to proof whether a combination of Springframework and Hibernate is still a "lightweight" or already a "heavyweight" champion. Please see following discussions in TSS for some of arguments:
My conclusions after working with Springframework and Hibernate in some of my projects are: yes, Springframework and Hibernate are already our heavyweight champions! Why?
  1. It's getting on my nerves as I have to create SpringBeans by editing those Spring XML files. This is the same with Hibernate hbml files. I know there are some tools available (e. g. Spring and Hibernate plugins) to help me finish these annoying works. But still... at the end this is just the same as working with EJB 2.x with those deployment descriptors. You might say, I can use annotations. The problem is I still have to deploy in JDK 1.4.x. So annotations just won't work. I also know that Springframework 2.0 uses XML schema so the XML files are easier and shorter to create, but again, I hate creating XML files by hand and you?
  2. Special for Springframework XML files and this is often the case: you need one XML file for remote client context, one XML file for local client context and one XML file for test? Gee, how many XML files should I write or copy and paste plus edit?
  3. Hibernate should protect us from the database behind it. Is this true? Until a certain level yes, but if you try to work with Oracle and at the same time with MySQL you will still need to understand the differences between those databases! Do you know that Oracle always saves "" (empty string) as a null value? And this is not the case with MySQL! So welcome back to the relational database!
  4. Do you know how many methods do we have in Hibernate just to persist or create a new object? What are these methods actually for: save, saveOrUpdate, persist, merge? Man, in SQL we just have one command: insert! Do we really need those different kind of methods just for a simple thing? Why can't we just say "save" and everything will be taken care by Hibernate?
  5. I think you already heard a lot about architecture discussion to DTO or not. If not you can check out some interesting discussion in Springframework forum: Transfer Objects. You also can find the same discussion in TSS: Protecting the Domain Model. So, what's the hell why we use POJO if we still have to use DTO? You don't need to use DTO at all - many of us would loudly say, but what if we need to physically separate the tiers? In this case you will meet the most hated exception in Hibernate: Lazy Loading error if you are not carefully design your POJO! So sometimes we need DTO and sometimes not?
  6. If you are by fall putting something wrong in the XML files - both Springframework and Hibernate - (not syntactically because your schema will help you in this case) and you get some errors because of these things. Good luck and have fun trying to find them!
So what are your options?
  1. Accept those points above and be sure to know them best. Why not? You think, the combination of Springframework and Hibernate is still easier to use than EJB 2.x? More flexible than EJB 3.x? Yes, you are right. So, better to have a bad solution than no solution at all. Wow, you are what I call a pragmatic Java programmer.
  2. Use AndroMDAwith the Springframework and Hibernate cartridges. Oh my, I don't want to have something to do with MDA and UML. But what are the advantages of AndroMDA? No need to create those damn XML files - both for Springframework and Hibernate - by hand. You have a standard architecture which will be strongly followed by everyone in your team (if you have one) all the time. Nothing like sometimes with DTO, sometimes without DTO. But still you need to implement those DTOs! Yes, but at least you have the skeletons created for you.
  3. Build your own Dependency Injection and your OR mapper framework which are far better than Springframework plus Hibernate and don't forget at the end you should put them as Open Source products and release them through TSS news :-) So we all can admire your new products: oooh a new very easy framework but also it can support any complex situations (= all you can eat framework - and yes, Springframework is probably getting in this direction too. Of course you don't need to use everything but... we have that, we have this, ... You know what I mean).
It seems that using the option number 2 you will get back those "lightweight" Springframework with Hibernate (no XML files - they will be generated and we always use the same architecture everywhere)? It could be. With the price of using UML? Is this still "lightweight" or we just move our weight somewhere else? At the moment I prefer to use the option number 2 as I feel that I have lot more advantages in comparison of using the option number 1 or 3. But this should not be a general case and should be proven case by case!
Allright, at the end I admit that there are actually no "heavyweight" or "lightweight" frameworks, everything are relative to what exist and to what you know. In any case just take one of your options above and try to solve the problems you need to solve for your customers.
Happy coding and greets,
Lofi.

Comments

lofidewanto said…
FYI: Some of interesting comments can be found here at JavaLobby:
http://www.javalobby.org/java/forums/t78583.html
Unknown said…
"With the price of using UML?"

Uhm.. You surely do some design before rush of the hack your code?

Or just simply start to punch in lines, hoping everything will turn out allright?

If the former, then what's wrong with UML?

If the later...
lofidewanto said…
"If the former, then what's wrong with UML?"

For me there is nothing wrong with UML but for many other developers? ;-)

First, you need to have an additional UML tool, which is at the moment quite limited. Second, you need to learn an additional UML language syntax and semantic.

So, I think not all developers want to have these additional burdens.

Lofi.

Popular posts from this blog

Software Development Macro and Micro Process

If you think that in year 2012 all companies which produce software and IT divisions in our world have already their optimized software development process, you are wrong. It seems that we - software architects, software developers or whatever your title is - still need to optimize the software development process in many software companies and IT divisions. So what do you do if you enter a software company or IT division and you see following things: 1. There is a perfect project management process to handle all those development of software but it is a pure project management without a context to software development. So basically you only take care of cost, time, budget and quality factors. In the software development you still use the old fashioned waterfall process. 2. From the tooling point of view: you have a project management planning and controlling tool but you are still in the beginning of Wiki (almost no collaboration tool) and you don't use issues tracking sy

Why "Polyglot Programming" or "Do It Yourself Programming Languages" or "Language Oriented Programming" sucks?

Last year we saw the launch of a new Web programming language Dart - Structured Web Programming from Google. A very interesting approach to support web application development. Not so long after Go, Groovy, Ruby, Scala, << name your DSL here >> ; we see Dart. Is it a good thing to have at least one programming language to solve one problem? The answer is, like we already know, it depends. Some important backgrounds you should know about the multi programming language paradigm are following: 1. You can read Martin Fowler article about language oriented programming with language workbenches which enables you to write small programming languages easily. In this article I see everyone writing their small languages, everywhere. In this concept we see DSL (Domain Specific Language) as the future of our programming activities. Source: http://martinfowler.com/articles/languageWorkbench.html 2. Neal Ford talked about Polyglot Programming, combining multiple programming language

Creating Spring Bean dynamically in the Runtime

In my training someone asked me whether it is possible to create an object (a Spring Bean) dynamically so you can choose which implementation you want to have  in the runtime . So at the compile time you don't know what object actually should be created yet. The application should decide what object to be created based on a property file . 1. We create an annotation so we can mark the method which should be able to create the object dynamically: ... package your.package; ... @Retention(RetentionPolicy.RUNTIME) public @interface InjectDynamicObject { } ... 2. Use the new created annotation in your method which should be able to create the object dynamically: ... @Named("customerBo") public class CustomerBoImpl implements CustomerBo { ...     @Override   @InjectDynamicObject   public Customer getDynamicCustomer() {         return this.dynamicCustomer; } ... 3. Write an aspect with Pointcut and Advise which change the ob