I have a java enum that I need to persist in the database. We are using MYSQL 5.0. I have several times done this and I have a class, the well-known StringEnumUserType, which I took from the Caveat Emptor sample application, that I am using for this purpose.
It's never given me trouble before, but now it's failing, with
Caused by: java.sql.SQLException: Data truncated for column 'OldState' at row 1 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3558) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3490) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2109) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2648) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2077) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2362) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2280) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2265) at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:94) at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:57)
Is there some maximum length of enumeration string representations that I am unaware of?
The value I am attempting to persist has a length of 10, with a total length of all possible values < 100. I can't make any sense of this. Do I need to put a length attribute on the property?
Also perhaps worthy of mention is that this is happening in a StatelessSession.insert() as opposed to a Session.save(). Not sure why that would make a difference but I'm clutching at straws here.
|