0

错误 SqlExceptionHelper - 不正确的整数值:'\xAC\xED\x00\x05sr\x00!com.domain.Client\xF3\xA5\x02\x0E\xC5d.\xA2\x02\x00\x0AJ\x00\x09clientKeyL\x00\第 1 行的“ClientKey”列的 x0AclientN'

我的道如下

@Entity
@Table(name = "M_FeedInputParams")
public class FeedInputParams {

    private Client clientKey;
@Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "ParamKey")
    private long paramKey;

    public long getParamKey() {
        return paramKey;
    }

    @Column(name = "FeedKey")
    public long getFeedKey() {
        return feedKey;
    }

    public void setFeedKey(long feedKey) {
        this.feedKey = feedKey;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "clientKey")
    @Column(name="ClientKey")
    public Client getClientKey() {
        return clientKey;
    }

    public void setClientKey(Client client) {
        this.clientKey = client;
    }}

堆栈跟踪

java.lang.RuntimeException: Incorrect integer value: '\xAC\xED\x00\x05sr\x00!com.vxl.appanalytix.domain.Client\xF3\xA5\x02\x0E\xC5d.\xA2\x02\x00\x0AJ\x00\x09clientKeyL\x00\x0AclientN' for column 'ClientKey' at row 1
    at com.dao.impl.FeedInputParamsDaoImpl.saveAll(FeedInputParamsDaoImpl.java:80)
    at com.dao.impl.FeedInputParamsDaoImpl.saveAllFeedInputParams(FeedInputParamsDaoImpl.java:66)
    at com.service.impl.FeedInputParamsServiceImpl.saveAllFeedInputParams(FeedInputParamsServiceImpl.java:37)
    at com.service.HandleUserOperationTest.saveAllDataFromUITest(HandleUserOperationTest.java:200)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
    at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
    at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.hibernate.exception.GenericJDBCException: Incorrect integer value: '\xAC\xED\x00\x05sr\x00!com.vxl.appanalytix.domain.Client\xF3\xA5\x02\x0E\xC5d.\xA2\x02\x00\x0AJ\x00\x09clientKeyL\x00\x0AclientN' for column 'ClientKey' at row 1
    at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
    at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:129)
    at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
    at com.sun.proxy.$Proxy39.executeUpdate(Unknown Source)
    at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:96)
    at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:58)
    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2936)
    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3447)
    at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:81)
    at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:362)
    at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:203)
    at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:183)
    at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:167)
    at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:320)
    at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:287)
    at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:193)
    at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:126)
    at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:204)
    at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:189)
    at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:114)
    at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
    at org.hibernate.internal.SessionImpl.fireSaveOrUpdate(SessionImpl.java:727)
    at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:719)
    at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:715)
    at com.vxl.appanalytix.dao.impl.FeedInputParamsDaoImpl.saveAll(FeedInputParamsDaoImpl.java:74)
    ... 31 more
Caused by: java.sql.SQLException: Incorrect integer value: '\xAC\xED\x00\x05sr\x00!com.domain.Client\xF3\xA5\x02\x0E\xC5d.\xA2\x02\x00\x0AJ\x00\x09clientKeyL\x00\x0AclientN' for column 'ClientKey' at row 1
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2734)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2458)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2375)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2359)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122)
    ... 54 more

首先我设置客户端表的客户端密钥并将客户端传递给FeedInputParams。当我执行它时出现错误,客户端密钥很长并且它在数据库中是bigint(20)

4

1 回答 1

0

未正确放置注释。应在注释字段或注释方法之间做出决定。在 JPA 2.0 规范中,这被告知如下。

如果无法确定默认访问类型并且未通过注释或 XML 描述符显式指定访问类型,则会出现错误。在没有明确指定 Access 注释的情况下,将注释放置在实体层次结构中的字段和属性上混合的应用程序的行为是未定义的。

在这种特定情况下,Hibernate 决定基于 @Id 注释在paramKey该字段中的访问是首选。因此方法中的注释getClientKey被忽略。可以通过将注释从getClientKey方法移动到clientKey字段来解决问题。

如果首选混合访问,则应使用@Access 。

于 2013-05-27T18:27:09.357 回答