I have just started with annotation based programming in Java. I was using xml based setups (hibernate) for configurations.
In annotations we have to write annotations within the java files, right. So, if we need to change something, then we would have to edit the java file, compile it again? Is this the correct way that I am understanding?
I read this question regarding the advantages of annotation in hibernate. But my question is not limited to hibernate.
UDPATE (Should not have used write once run anywhere in question)
In case of xml based-config, we just make changes and restart the app that it right?
But in case of annotations, we would require to again re-compile, re-deploy and re-start the app. Isn't this a disadvantage?
No absolutely not!
To reflect the changes made in your source code you have to compile and run the code again and is true for all programming languages. Only use of annotations or xml configuration files is to ease the project setup, debug and running.Even if you have xml/annotation for your project(Ex Spring or Hibernate) you have to recompile the project to reflect your changes.
"write once run anywhere" paradigm is that when we compile any java code it gets converted into bytes code which can run on any OS/Platform. All you need is the JVM installed which actually understand and runs the java code.
Updated Question Answer : Again the answer is no! It is not at all a disadvantage. In face it is a feature to prevent writing more code(So that you can concentrate more on your business logic). You have to choose the right combination for your project. For example recently i worked on Spring and I used both xml configs and annotations
. xml config has the configurations that are user configurable where as annotations are mostly used more for flow control. For example annotation in my case dictated what to be executed before a bean is create or after. Same is the case with most of the annotations based code. It is used to tell JVM that specified functionality is for specified condition but the data required for processing is obtained from xml configs.