Error:ORA-01461: can bind a LONG value only for insert into a LONG column
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>
}
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.
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.
精彩评论