java.sql.SQLException: Invalid column index in wildfly

为君一笑 提交于 2019-12-12 02:42:39

问题


I upgraded jboss 7 to wildfly 10 but there is a strange error which I couldn't understand why

The exception:

Caused by: java.sql.SQLException: Invalid column index at oracle.jdbc.driver.OraclePreparedStatement.setLongInternal(OraclePreparedStatement.java:4901) at oracle.jdbc.driver.OraclePreparedStatement.setLong(OraclePreparedStatement.java:4888) at oracle.jdbc.driver.OraclePreparedStatementWrapper.setLong(OraclePreparedStatementWrapper.java:206) at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setLong(NewProxyPreparedStatement.java:703) at org.hibernate.type.descriptor.sql.BigIntTypeDescriptor$1.doBind(BigIntTypeDescriptor.java:46) at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:73) at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:257) at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:252) at org.hibernate.persister.entity.AbstractEntityPersister.dehydrateId(AbstractEntityPersister.java:2636) at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2604) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2883)

It looks like hibernate is trying to convert datatype as wildfly is using newer version of hibernate

Generated sql which works fine when I run directly on oracle:

Error in processing CreateProvisiningBaseServiceImpl: org.springframework.orm.hibernate3.HibernateJdbcException: JDBC exception on Hibernate data access: SQLException for SQL [insert into NE_NOTIFICATION_INPUT (CREATION_DATE, FILE_NAME, INPUT_TYPE, INPUT_ID) values (?, ?, 'NotificationInput', ?)]; SQL state [99999]; error code [17003]; could not insert: [com.ericsson.enk.ne.db.model.NotificationInput]; nested exception is org.hibernate.exception.GenericJDBCException: could not insert: [com.ericsson.enk.ne.db.model.NotificationInput]

There is also something weird. When I remove the table, the error doesnt change. But when I remove the sequence, the error changes and says it cannot find sequence.

Java code for sequence is below:

@Id
@Column(name = "INPUT_ID", nullable = false)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "inputSequence")
@SequenceGenerator(name = "inputSequence", sequenceName = "SEQ_INPUT_ID", allocationSize = 1)
public long getInputId() {
    return inputId;
}

回答1:


I narrowed down problem to JPA. It looks like problem is related to JPA upgrade from 2.0 to 2.1. As it is stated in question below, Discriminator mapping should be updated with "insertable = false, updatable = false" annotation Error when trying to insert an extended entity: invalid column index



来源:https://stackoverflow.com/questions/36599888/java-sql-sqlexception-invalid-column-index-in-wildfly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!