title: Way to automatically truncate a String column using JPA / Spring / Hibernate?
body: <p>I'm using Spring 3.1.1.RELEASE, JPA 2.0, and Hibernate 4.1.0.Final.  I have a MySQL 5.5 column of VARCHAR(100) type.  If I save an entity whose value is larger than 100 characters, unsurprisingly, the save fails with the error</p>
  
  <pre><code>SQL [n/a]; nested exception is org.hibernate.exception.DataException: Data truncation: Data too long for column 'MY_COL' at row 1
  </code></pre>
  
  <p>org.springframework.dao.DataIntegrityViolationException: Data truncation: Data too long for column</p>
  
  <p>Is there a way to set Spring/Hibernate/JPA so that if my String value is too long, the data will be automatically truncated to the maximum length?  I realize I could add code to automatically check if the String is 100 characters and then truncate the String with Java, but I wa curious if there's a less rigorous way to do this.</p>