Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

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

DZone's Guide to

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

· Java Zone
Free Resource

Learn how our document data model can map directly to how you program your app, and native database features like secondary indexes, geospatial and text search give you full access to your data. Brought to you in partnership with MongoDB.

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

Discover when your data grows or your application performance demands increase, MongoDB Atlas allows you to scale out your deployment with an automated sharding process that ensures zero application downtime. Brought to you in partnership with MongoDB.

Topics:

Published at DZone with permission of Lukas Eder, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}