java.sql.DataTruncation: Data truncation异常

Could not synchronize database state with session
 org.hibernate.exception.DataException: could not insert: [com.cddts.uphold.checkrecord.vo.FwzcWeekInspector]
 at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:100)
 at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
 at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2295)
 at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2688)
 at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)
 at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
 at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
 at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
 at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions.java:237)
 at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)

Caused by: java.sql.DataTruncation: Data truncation
 at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:382)
 at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2820)
 at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2258)
 at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:632)
 at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.java:584)
 at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:546)
 at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeUpdate(JtdsPreparedStatement.java:504)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.logicalcobwebs.proxool.ProxyStatement.invoke(ProxyStatement.java:68)
 at org.logicalcobwebs.cglib.proxy.Proxy$ProxyImpl$$EnhancerByCGLIB$$aa485b56.executeUpdate(<generated>)
 at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:46)
 at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2275)
 ... 100 more

 

 

 

 

以上异常是数据库数据存储时,超出字段大小导致。
id 在自动生成时超出字段长度     字段为varchar(20),

<id name="id" type="java.lang.String">
            <column name="id" length="20" />
            <generator class="uuid.hex" />
        </id>

修改成50

你可能感兴趣的:(java,sql,Hibernate,.net,jdbc)