2014-05-14 08:41:02
Error in : org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1215)
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1148)
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1154)
org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:695)
sun.reflect.GeneratedMethodAccessor193.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)
com.sun.proxy.$Proxy82.merge(Unknown Source)
com.REP.CompanyAcce.pat.dao.BaseDAO.save(BaseDAO.java:50)
sun.reflect.GeneratedMethodAccessor250.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
com.sun.proxy.$Proxy84.save(Unknown Source)
com.REP.CompanyAcce.pat.service.PATThreadService.saveCandidatesData(PATThreadService.java:561)
com.REP.CompanyAcce.pat.service.PATThreadService.collectCandidateData(PATThreadService.java:200)
com.REP.CompanyAcce.pat.service.PATThreadService$CollectCandidateDataThread.run(PATThreadService.java:90)
java.lang.Thread.run(Thread.java:662)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
java.lang.Thread.run(Thread.java:662)
org.hibernate.exception.GenericJDBCException: could not insert: [com.REP.CompanyAcce.pat.entity.PATCandidatesData]javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not insert: [com.REP.CompanyAcce.pat.entity.PATCandidatesData] at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1215) at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1148) at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1154) at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:695) at sun.reflect.GeneratedMethodAccessor193.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240) at com.sun.proxy.$Proxy82.merge(Unknown Source) at com.REP.CompanyAcce.pat.dao.BaseDAO.save(BaseDAO.java:50) at sun.reflect.GeneratedMethodAccessor250.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at com.sun.proxy.$Proxy84.save(Unknown Source) at com.REP.CompanyAcce.pat.service.PATThreadService.saveCandidatesData(PATThreadService.java:561) at com.REP.CompanyAcce.pat.service.PATThreadService.collectCandidateData(PATThreadService.java:200) at com.REP.CompanyAcce.pat.service.PATThreadService$CollectCandidateDataThread.run(PATThreadService.java:90) at java.lang.Thread.run(Thread.java:662) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) at java.lang.Thread.run(Thread.java:662) Caused by: org.hibernate.exception.GenericJDBCException: could not insert: [com.REP.CompanyAcce.pat.entity.PATCandidatesData] at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140) at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:64) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2345) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2852) at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:71) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:320) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:203) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:129) at org.hibernate.ejb.event.EJB3MergeEventListener.saveWithGeneratedId(EJB3MergeEventListener.java:62) at org.hibernate.event.def.DefaultMergeEventListener.saveTransientEntity(DefaultMergeEventListener.java:415) at org.hibernate.event.def.DefaultMergeEventListener.mergeTransientEntity(DefaultMergeEventListener.java:341) at org.hibernate.event.def.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:303) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:258) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:84) at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:867) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:851) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:855) at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:686) ... 23 more Caused by: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x92\xBC' for column 'HEADLINE' at row 1 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3603) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3535) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1989) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2150) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2626) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2415) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2333) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2318) at org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:493) at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:94) at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:57) ... 40 more
I created table like this:-
我创建了这样的表:-
DROP TABLE IF EXISTS `aa`;
CREATE TABLE `aa` (
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`Rins` varchar(45) NOT NULL,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Then
然后
ALTER TABLE aa MODIFY Rins VARCHAR(45) CHARACTER SET UTF8 COLLATE utf8_polish_ci;
修改表aa修改Rins VARCHAR(45)字符集UTF8 COLLATE utf8_polish_ci;
But still I am getting Exception
但我还是有例外
Caused by: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x92\xBC' for column 'Rins' at row 1 at com.mysql.jdbc.SQL
引起的:java.sql。SQLException:不正确的字符串值:“\xF0\x9F\x92\xBC”,列“Rins”在com.mysql.jdbc.SQL的第1行
2 个解决方案
#1
3
I guess you're only using utf-8.
我猜你只使用utf-8。
In your CREATE TABLE try this...
在创建表中,尝试以下操作……
`Rins` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL
utf-8 only supports Basic Multilingual Planes wherein your special characters do not belong. So you have to use utf8mb4 instead
utf-8只支持基本的多语种飞机,其中您的特殊字符不属于。所以你必须使用utf8mb4
and your Mysql should be 5.5+
你的Mysql应该是5.5+。
this thread can give you more explanation... java.sql.SQLException: Incorrect string value: '\xF0\x9F\x91\xBD\xF0\x9F…'
这条线可以给你更多的解释……java.sql。\xF0\x9F\x91\xBD\xF0\ xF0\x9F…
#2
0
The character the error refers to "U+1F4BC" is a supplemental character not supported by utf8 in mysql. You should try using utf8mb4 instead.
错误引用的字符“U+1F4BC”是mysql中不支持utf8的补充字符。您应该尝试使用utf8mb4。
For a supplementary character, utf8 cannot store the character at all, while utf8mb4 requires four bytes to store it. Since utf8 cannot store the character at all, you do not have any supplementary characters in utf8 columns and you need not worry about converting characters or losing data when upgrading utf8 data from older versions of MySQL.
对于补充字符,utf8根本无法存储该字符,而utf8mb4需要4个字节来存储该字符。由于utf8根本无法存储该字符,因此在utf8列中没有任何补充字符,在从旧版本的MySQL升级utf8数据时,也不必担心转换字符或丢失数据。
#1
3
I guess you're only using utf-8.
我猜你只使用utf-8。
In your CREATE TABLE try this...
在创建表中,尝试以下操作……
`Rins` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL
utf-8 only supports Basic Multilingual Planes wherein your special characters do not belong. So you have to use utf8mb4 instead
utf-8只支持基本的多语种飞机,其中您的特殊字符不属于。所以你必须使用utf8mb4
and your Mysql should be 5.5+
你的Mysql应该是5.5+。
this thread can give you more explanation... java.sql.SQLException: Incorrect string value: '\xF0\x9F\x91\xBD\xF0\x9F…'
这条线可以给你更多的解释……java.sql。\xF0\x9F\x91\xBD\xF0\ xF0\x9F…
#2
0
The character the error refers to "U+1F4BC" is a supplemental character not supported by utf8 in mysql. You should try using utf8mb4 instead.
错误引用的字符“U+1F4BC”是mysql中不支持utf8的补充字符。您应该尝试使用utf8mb4。
For a supplementary character, utf8 cannot store the character at all, while utf8mb4 requires four bytes to store it. Since utf8 cannot store the character at all, you do not have any supplementary characters in utf8 columns and you need not worry about converting characters or losing data when upgrading utf8 data from older versions of MySQL.
对于补充字符,utf8根本无法存储该字符,而utf8mb4需要4个字节来存储该字符。由于utf8根本无法存储该字符,因此在utf8列中没有任何补充字符,在从旧版本的MySQL升级utf8数据时,也不必担心转换字符或丢失数据。