3 Replies Latest reply on Oct 4, 2006 2:48 AM by andydale

    Where to place annotations?

      Are annotations to be placed on getters, setters, or the fields themselves? (Do we have multiple options.)

      Must we remain consistent between classes?

      What about within classes?

      Is there any functional difference between putting the annotations in one place vs another?

        • 1. Re: Where to place annotations?

          Is there any functional difference between putting the annotations in one place vs another?

          Yes, Eclipse will usually pick up on the error.
          Don't know about fields themselves, but getters and setters depends on whether or not you need to set TransactionAttributes.

          • 2. Re: Where to place annotations?

            Perhaps I should clarify. I mean annotations such as Column that intuitively could appear in either place.

            • 3. Re: Where to place annotations?
              andydale

              lightbulb,

              I personally think it is better to annotate the getter methods, as i used to annotate the fields themselves and ran into a few errors (Hibernate MappingException) when using relations between the Entities.

              Just remember that what ever you do, it should be consistent i.e annotaye only the getters or only the fields.

              Cheers,

              Andy