views:

66

answers:

1

I use Project Lombok to automatically generate getter and setter methods for all fields of a Java class.

When a field is annotated with e.g. @XmlTransient, the annotation is not propagated to the generated getter/setter methods, thus in the resulting code it does not show any effect. Is there a way to use automatic getter/setter generation in conjunction with further annotations?

+2  A: 

I don't think propagating annotations to getter/setter methods would work in the generalt case. For example do you know what would happen if both the field and the bean properties were annotated with @XmlElement? For JAXB annotations I would suggest using @XmlAccessorType(XmlAccessType.FIELD) on the field.

Jörn Horstmann
Yes, that's what i was looking for! '@XmlAccessorType(XmlAccessType.FIELD)' at class level notifies JAXB to use the attributes for the XML mapping (and not the getter or setter methods), see e.g. http://www.devx.com/Java/Article/34069/1763/page/3 . Thank's a lot!
rmv