Platinum Partner
java,sql,framework

Annotatiomania™, or Why Did Hibernate/JPA Get So Complex?

I was curious about good answers to this question on Stack Overflow:

http://stackoverflow.com/questions/7332904/how-to-store-a-collection-of-dates-in-hibernate

And a good answer came up, pointing at this Hibernate documentation page:

http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/collections.html#collections-ofvalues

Is anyone out there actually willing to mess around with gazillions of annotations on simple methods? Who ever writes this stuff:

@Entity
public class User {
   [...]
   public String getLastname() { ...}

   @ElementCollection
   @CollectionTable(
      name="Addresses", 
      joinColumns=@JoinColumn(name="user_id"))
   @AttributeOverrides({
      @AttributeOverride(
         name="street1", 
         column=@Column(name="fld_street"))
   })
   public Set<Address> getAddresses() { ... }
}

@Embeddable
public class Address {
   public String getStreet1() {...}
   [...]
}

Do some developers despise SQL so much that they’re willing to put up with “annotatiomania”? Whatever happened with the good old

SELECT u.first_name, u.last_name, a.street1
FROM users u
JOIN addresses a ON a.user_id = u.id

Guys. If a technology starts doing things like “@AttributeOverrides”, then something IS smelling fishy

Published at DZone with permission of {{ articles[0].authors[0].realName }}, DZone MVB. (source)

Opinions expressed by DZone contributors are their own.

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}