-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Data Trunctation Problem Persisting MYSQL Enum
PostPosted: Thu Jan 27, 2011 1:54 pm 
Regular
Regular

Joined: Tue Oct 10, 2006 2:21 pm
Posts: 58
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.


Top
 Profile  
 
 Post subject: Re: Data Trunctation Problem Persisting MYSQL Enum
PostPosted: Thu Jan 27, 2011 6:55 pm 
Regular
Regular

Joined: Tue Oct 10, 2006 2:21 pm
Posts: 58
Duuuuhhh! Never Mind!

It would have helped had I used the <typedef> I defined in the properties of this type. Without a typedef, who knows what Hibernate was trying to do, but it could not have been what I wanted it to.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.