Wednesday, January 18, 2012

Hibernate: BLOB/TEXT column 'field_id' used in key specification without a key length

Working with Hibernate and JPA I've had a problem generating a schema. The generation would fail with following message:

org.hibernate.tool.hbm2ddl.SchemaUpdate - main   - BLOB/TEXT column 'field_id' 
used in key specification without a key length

The JPA mapping causing the problem looked like following:
 
@Column(name = prefix + "field_id", length = 256, unique=true, nullable=false)
private String fieldId;

Apparently, using hibernate in combination with MySQL causes this failure. The key element on the mapping is the length attribute. I've had to change it to length=255 and everything worked again.
@Column(name = prefix + "field_id", length = 255, unique=true, nullable=false)
private String fieldId;

Give it a try!

Friday, January 13, 2012

Debugging mvn tomcat:run on a Macintosh

I did have a hard time to figure out how remote debugging with eclipse and the tomcat-maven-plugin works on a Mac. On windows I used a script which looks like following:

set MAVEN_OPTS=-Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
mvn tomcat:run

To achieve the same thing on a Mac just change the script to following:

export MAVEN_OPTS="-Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
mvn tomcat:run