错误:ORA-01461:只能绑定 LONG 值以插入 LONG 列

发布于 2024-11-27 21:55:46 字数 1587 浏览 2 评论 0原文

我正在使用 wsdl2java 生成 POJO。然后向 POJOS 添加 @Entity 注释。然后使用 hbm2ddl 生成数据库模式和持久化数据。它适用于我的所有类文件,除了一个。将 POJO 保存到 Oracle 11g 数据库时,出现以下错误

java.sql.BatchUpdateException: ORA-01461: can bind a LONG value only for insert into a LONG column
at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10656)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
... 11 more

无法弄清楚是什么原因导致的?请帮助我。

我的 POJO 类是 -

@Entity
public class ServiceTrain  implements java.io.Serializable {
private java.lang.String accountName;

private short applicationModeId;

private java.lang.String cityLocation;

private short countryId;

private java.lang.String customerCompany;

private java.lang.Long customerHoldingId;

private java.util.Calendar lastChangedAt;

private short loadModeId;

private short marketId;

private short marketSegmentId;

private java.lang.String operatorCompany;

private java.lang.Long operatorHoldingId;

private short plantTypeId;

private java.lang.String postalCode;

private java.lang.Integer provinceStateId;

private short responsibleCountryId;

private com.siemens.scr.ServicePlantObjects[] servicePlantObjectsArray;

@Id
private long serviceTrainId;

private java.lang.String streetAddress;

private java.lang.String trainName;

public ServiceTrain() {
}
....
.... <getters & setters>
}

I am using wsdl2java to generate POJOs. Then added @Entity annotations to the POJOS. Then using hbm2ddl for generating the db schema & persisting the data. It works well for all my class files except one. While saving the POJO into the Oracle 11g db I get the following error

java.sql.BatchUpdateException: ORA-01461: can bind a LONG value only for insert into a LONG column
at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10656)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
... 11 more

Cant figure out whats causing this? Pls help me.

My POJO class is -

@Entity
public class ServiceTrain  implements java.io.Serializable {
private java.lang.String accountName;

private short applicationModeId;

private java.lang.String cityLocation;

private short countryId;

private java.lang.String customerCompany;

private java.lang.Long customerHoldingId;

private java.util.Calendar lastChangedAt;

private short loadModeId;

private short marketId;

private short marketSegmentId;

private java.lang.String operatorCompany;

private java.lang.Long operatorHoldingId;

private short plantTypeId;

private java.lang.String postalCode;

private java.lang.Integer provinceStateId;

private short responsibleCountryId;

private com.siemens.scr.ServicePlantObjects[] servicePlantObjectsArray;

@Id
private long serviceTrainId;

private java.lang.String streetAddress;

private java.lang.String trainName;

public ServiceTrain() {
}
....
.... <getters & setters>
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蓬勃野心 2024-12-04 21:55:46

当我发现我试图在 Varchar2 字段中输入 4000 多个字符串时,我解决了这个问题。

我减少了条目的长度,错误就消失了。

表中还有其他 NUMBER 字段,这让我一开始就迷失了方向。

I solved it when I figured out that I was trying to enter a 4000+ character string into a Varchar2 field.

I reduced the length of the entry and the error went away.

There were other NUMBER fields in the table, which threw me off the trail initially.

抚笙 2024-12-04 21:55:46

我实在不知道这个问题的原因。但每次我向表中插入一条记录时,都通过创建一个新的 ServiceTrain bean 来解决这个问题。由于某种奇怪的原因,这工作得很好。

I really don't know the cause of this issue. But got this resolved by creating a new ServiceTrain bean each time i insert a record to the table. For some strange reason this works fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文