Good Times

My typically random thoughts…

JPA notes

I really like the JPA spec & Hibernate’s implementation of it. It’s been easy to work with and fairly intuitive. I ran into two things today that were worth commenting on though.

  1. It’s worth your effort in being consistent in how you update the Database Schema; If you use scripts, do it always, if you use the JPA provider, do it always. I use the hibernate envers plugin and really like it, but if you do updates through your DB console or w/ scripts and forget about the *_revisions table, you can get weird type conversion or size problems that are unclear. During my dev cycle, I like dropping the schema and recreating it from scratch to ensure everything is right. You can even generate your production script from that when dif’d w/ previous production DB script…
  2. The length attribute on a @Column annotation where the type is a String always generates a VARCHAR(mylength) database column. If you want a TEXT or CLOB field, you need to use the @Lob annotation & then the length attribute is irrelevant.

As usual, it seems obvious in retrospect, but was weird when dealing w/ the errors.

Friday, 9/9/2011 Posted by | Uncategorized | Leave a Comment

   

Follow

Get every new post delivered to your Inbox.