Monday, September 8, 2008

Annotation Hell

XML Hell, the phenomenon that killed struts, and fear of which launch Seam. Annotations were the savior, so the prophets proclaimed. But have we gone too far? You decide.
* @return related details for this person
@ManyToOne( fetch = FetchType.EAGER, cascade =
{ javax.persistence.CascadeType.PERSIST, javax.persistence.CascadeType.MERGE } )
@JoinColumn( name = "PERSON_DETAIL", nullable = false )
@Where( clause = "ACTV_ID = 'T'" )
@Cascade( { CascadeType.SAVE_UPDATE, CascadeType.MERGE, CascadeType.DELETE } )
@Cache( usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE )
@Message( "${msg.invalid.person.detail}" )
@XmlElement( name = "person-detail", required = true )
public PersonDetail getPersonDetail()
return personDetail;
This is a method of a Hibernate ORM object which can be serialized via JAXB. Also utilizes Hibernate validation, an i18n Message manager and EqualsMember, which means this element is a member of the set of fields denoting object equality. Somehow, I'm starting to miss XML...


Shawn Hartsock said...

I've been calling this "annotation buildup" myself.

Anonymous said...


i think we are going to declare annotations which the class has in another dedicated files and then those files will turn into dsl-specific xml-like files again !!! looop :-]

Luxspes said...

That is hellish, and it gets even worse if you consider that the annotations:

@Column(nullable = false )

can be configured to contradict each other, for example:

@Column(nullable = false)




@Column(nullable = false )

Why so much redundancy? Nobody knows, nobody cares, and nobody deals with it in a consistent way.

They do not even deal with this consistently even if you use only 1 of this confusing annotations: @Column. For example:

@Column(nullable = false ) is an schema level hint acording to the spec, but while EclipseLink respects that, Hibernates treats it as if were an object level validation.