为什么Hibernate会引发无效的列名异常?

时间:2017-05-13 15:54:30

标签: java spring oracle hibernate

我的查询在oracle中运行但在我的java代码中选择wuery会抛出无效的列名。 我的实体:

@Basic
@Column(name = "kasr_uni", columnDefinition = "VARCHAR2(100)")
private String kasr_uni;

我的查询类:

@Repository
@Transactional
public class ExportManagerImpl implements ExportManager {
@PersistenceContext
private EntityManager entityManager;

    @Override
    public List getAllUnis() {
        return entityManager.createNativeQuery("SELECT kasr_uni FROM KASR GROUP BY kasr_uni ORDER BY kasr_uni ASC",Kasr.class).getResultList();
    }
}

异常:

  java.sql.SQLException: Invalid column name
oracle.jdbc.driver.OracleStatement.getColumnIndex(OracleStatement.java:3757)
oracle.jdbc.driver.InsensitiveScrollableResultSet.findColumn(InsensitiveScrollableResultSet.java:264)
oracle.jdbc.driver.GeneratedResultSet.getLong(GeneratedResultSet.java:558)
org.hibernate.type.descriptor.sql.BigIntTypeDescriptor$2.doExtract(BigIntTypeDescriptor.java:73)
org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64)
org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:267)
org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:263)
org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:253)
org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:338)
org.hibernate.loader.Loader.extractKeysFromResultSet(Loader.java:785)
org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:721)
org.hibernate.loader.Loader.processResultSet(Loader.java:953)
org.hibernate.loader.Loader.doQuery(Loader.java:921)

0 个答案:

没有答案