gpt4 book ai didi

java - 错误 SqlExceptionHelper - 整数值不正确

转载 作者:行者123 更新时间:2023-11-30 01:36:45 26 4
gpt4 key购买 nike

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

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

最佳答案

注释放置不正确。应该在注释字段或注释方法之间做出决定。 JPA 2.0 规范中对此进行了如下说明。

It is an error if a default access type cannot be determined and an access type is not explicitly specified by means of annotations or the XML descriptor. The behavior of applications that mix the placement of annotations on fields and properties within an entity hierarchy without explicitly specifying the Access annotation is undefined.

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

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

关于java - 错误 SqlExceptionHelper - 整数值不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16772348/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com