0

I just had one query:

Iam developing one internal project myself (mixing of spring, hibernate, dao)..

Iam thinking like this: Just using annotations only for hibernate and xml configurations in case of spring.

what u suggest me? (Using annotations in Spring is better than XML configurations?)

pls i need your suggestion..

iam really not understanding when exactly I have to use annotations and when shouldnt..

Iam not much very good at annotations, but had a enough knwoledge, so you suggest me to learn it?

Irwin
  • 105
  • 1
  • 2
  • 7

2 Answers2

1

The argument for using XML configuration was that you didn't need to rebuild to change the meta data.

In my experience, all that happens with making an XML config rather than annotation is it just sits there and festers once you've written it. Think about it this way, how often do you really change a table structure once it works?

Annotations mean you don't need to keep chopping and changing out of your entity class into your xml or have pages of XML to go through.

David
  • 19,577
  • 28
  • 108
  • 128
  • So you never use xml file at all for configuration purposes? if YES, in what situation we should go with Xml file configuration? please kindly be clear me this.iam really not understanding when exactly I have to use annotations and when shouldnt. – Irwin Feb 20 '13 at 18:53
  • I'm not saying I would NEVER use XML - I would say, if the code was already using XML but for a rule of thumb I wouldn't use it unless I had to (for instance there was a reason why I wanted to change the meta data without recompiling, I have never had this happen). But if I am ever building software now, I always use annotation simply out of personal preference if I'm honest. – David Feb 20 '13 at 21:54
  • Atleast can u able to explain with any example showing that so and so case cannot be used Annotations (only xml's preferred), can U pls? – Irwin Feb 21 '13 at 05:04
0

There is no right answer its personal preference, my very unscientific straw poll is most people prefer annotations. However people you work with may be used to xml config, we hired someone new and they were used to developing using the XML files, so we re-educated them.

You can override annatotions by supplying an XML config - but that would be a indicative of a mess.

(also, intellij makes a much bigger difference with spring, the ability to click on vritualyl any bean reference anyway and it takes you to its decalration is great)

NimChimpsky
  • 46,453
  • 60
  • 198
  • 311
  • So you never use xml file at all for configuration purposes? if YES, in what situation we should go with Xml file configuration? please kindly be clear me this.. – Irwin Feb 20 '13 at 18:23