Hibernate在自己的类型上无效列

时间:2013-02-27 18:06:30

标签: java oracle hibernate oracle11g

我有以下选择我要用hibernate和java映射(在oracle数据库11g上):

SELECT a.COL1 TSTRING(CAST(collect(distinct(substr(COLUMN,5)) order COLUMN asc) AS OWN_TYP)) FROM TABLE a

如果我在sqldeveloper中执行此查询,则可以正常工作。函数TSTRING是一个自己的函数,它将值转换为字符串。但我没有写这样的数据类型OWN_TYP。我只使用它,在数据库上它工作正常但在java中使用以下代码:

SQLQuery qu = q.getQuery(SQL);
qu.setFetchSize(Integer.valueOf(1000));
qu.setReadOnly(true);
if(qu!=null){
    ScrollableResults results = qu.scroll(ScrollMode.FORWARD_ONLY);

它抛出异常:

WARN  org.hibernate.engine.jdbc.spi.SqlExceptionHelper - SQL Error: 17006, SQLState: 99999
ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper - Ungültiger Spaltenname
org.hibernate.exception.GenericJDBCException: Ungültiger Spaltenname

我正在使用ojdbc6.jar,这是我的hibernate xml文件:

<hibernate-configuration>

<session-factory>

    <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
    <property name="connection.url">jdbc:oracle:thin:@localhost:1521:DB</property>
    <property name="connection.username">USER</property>
    <property name="connection.password">PW</property>
    <property name="default_schema">SCHEMA</property>
    <property name="dialect">de.tool.datastructures.OracleDialect</property>

    <property name="hibernate.connection.hsqldb.default_table_type">cached</property>

    <!-- JDBC connection pool (use the built-in) -->
    <property name="connection.pool_size">1</property>

    <!-- turn off SQL batches: this must be 0 when debugging,
         otherwise the Exceptions are not useful at all!!! -->
    <property name="hibernate.jdbc.batch_size">0</property>

    <!-- Enable Hibernate's automatic session context management -->
    <property name="current_session_context_class">thread</property>

    <!-- Disable the second-level cache  -->
    <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

    <!-- Echo all executed SQL to stdout -->
    <property name="show_sql">false</property>

    <!-- Drop and re-create the database schema on startup -->
    <!--<property name="hbm2ddl.auto">update</property>-->

</session-factory>

0 个答案:

没有答案