Friday, May 15, 2009

Lazier DDL with Spring's HibernateJpaVendorAdapter

Ok, so let's get one thing straight. I am an extremely lazy guy. And no, I am not talking about only loading collections of my friends after someone tries to access them directly. No.

I am talking about procrastination.

At my levels (software engineering) it is an art form. For example, today I had to write some SQL code - code that creates a new table in a database. Here's how I did it:

  1. Create a new class, and annotate it with @Entity (javax.persistence.Entity)
  2. Add fields. As many as you want.
  3. Use IDE to generate getters and setters for those fields.
  4. You're already using HibernateJpaVendorAdapter. You're not???! Beat it, man. Ok now just call the method .setGenerateDdl(true) on it.
  5. The eeeennnnnd.
Well, that took 30 seconds!

No comments:

Post a Comment

 
Clicky Web Analytics