我收到错误“无效的列名称”

发布于 2024-12-13 05:11:39 字数 5246 浏览 0 评论 0原文

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.vijay.Transfee" table="TRXN_FEE_TABLE">
<meta attribute="class-description">
This class contains the course details.
</meta>
<id name="Tcode" type="string" column="TRXN_FEE_CODE" >
    </id>
<property name="Icode" type="string" column ="INSTCODE" />
<property name="Pcode" type="string" column ="PRODUCT_CODE" />
<property name="Tcode1" type="string" column ="TRANSACTION_CODE" />
<property name="rebate_code1" type="string" column="REBATE_CODE"/>
</class>
<sql-query name="F_SP" callable="true">
    <return alias="fee"  class="com.vijay.Transfee">
        <return-property name="rebate_code1" column="REBATE_CODE"/>
    </return>
    { call Feeproc1(?) }
 </sql-query>
</hibernate-mapping>

package com.vijay;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

import java.util.*;

public class A {

    public static void main(String[] args){

        Configuration config = new Configuration();
        SessionFactory factory = config.configure().buildSessionFactory();
        System.out.println(">>>>>>>>1");
        Session session = factory.openSession();
        Transaction tx = session.beginTransaction();
        Query query = (Query)session.getNamedQuery("F_SP"); 
        System.out.println(">>>>>>>>2");
        List result = query.list();
        System.out.println(query.list());
        Iterator it=result.iterator();
        while(it.hasNext())
        {
            Object[] sublist1 = (Object[])it.next();
            System.out.println(">>>>>>>>3");
            String Trx = (String)sublist1[0];
            System.out.println(">>>>>>>>4");
            System.out.println(Trx);
        }
        System.out.println(">>>>>>>>5");
        System.out.println(result);
}
}

我正在调用存储过程并仅打印我调用的存储过程,但它显示以下错误

    
    Exception in thread "main" org.hibernate.exception.GenericJDBCException: could not execute query
        at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
        at org.hibernate.loader.Loader.doList(Loader.java:2536)
        at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
        at org.hibernate.loader.Loader.list(Loader.java:2271)
        at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:316)
        at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1842)
        at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
        at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:157)
        at com.vijay.A.main(A.java:24)
    Caused by: java.sql.SQLException: Invalid column name
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:113)
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:147)
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:209)
        at oracle.jdbc.driver.OracleStatement.getColumnIndex(OracleStatement.java:3325)
        at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:1926)
        at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1515)
        at org.hibernate.type.descriptor.sql.VarcharTypeDescriptor$2.doExtract(VarcharTypeDescriptor.java:61)
        at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64)
        at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:254)
        at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:250)
        at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:230)
        at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:331)
        at org.hibernate.loader.Loader.extractKeysFromResultSet(Loader.java:668)
        at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:606)
        at org.hibernate.loader.Loader.doQuery(Loader.java:829)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
        at org.hibernate.loader.Loader.doList(Loader.java:2533)
        ... 7 more
CREATE OR REPLACE PROCEDURE LYCAMONEY.Feeproc1(p_cursor  OUT  sys_refcursor)
as rebate_code1 varchar2(20);
begin

  rebate_code1 := null;
  open p_cursor for
    select REBATE_CODE into rebate_code1  from TRXN_FEE_TABLE;

 dbms_output.put_line(rebate_code1 );

end;
/

任何人都可以帮助我解决此问题......并发布正确的方法,如果

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.vijay.Transfee" table="TRXN_FEE_TABLE">
<meta attribute="class-description">
This class contains the course details.
</meta>
<id name="Tcode" type="string" column="TRXN_FEE_CODE" >
    </id>
<property name="Icode" type="string" column ="INSTCODE" />
<property name="Pcode" type="string" column ="PRODUCT_CODE" />
<property name="Tcode1" type="string" column ="TRANSACTION_CODE" />
<property name="rebate_code1" type="string" column="REBATE_CODE"/>
</class>
<sql-query name="F_SP" callable="true">
    <return alias="fee"  class="com.vijay.Transfee">
        <return-property name="rebate_code1" column="REBATE_CODE"/>
    </return>
    { call Feeproc1(?) }
 </sql-query>
</hibernate-mapping>

package com.vijay;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

import java.util.*;

public class A {

    public static void main(String[] args){

        Configuration config = new Configuration();
        SessionFactory factory = config.configure().buildSessionFactory();
        System.out.println(">>>>>>>>1");
        Session session = factory.openSession();
        Transaction tx = session.beginTransaction();
        Query query = (Query)session.getNamedQuery("F_SP"); 
        System.out.println(">>>>>>>>2");
        List result = query.list();
        System.out.println(query.list());
        Iterator it=result.iterator();
        while(it.hasNext())
        {
            Object[] sublist1 = (Object[])it.next();
            System.out.println(">>>>>>>>3");
            String Trx = (String)sublist1[0];
            System.out.println(">>>>>>>>4");
            System.out.println(Trx);
        }
        System.out.println(">>>>>>>>5");
        System.out.println(result);
}
}

I am calling the stored procedure and just printing the one i called but it shows the following error

    
    Exception in thread "main" org.hibernate.exception.GenericJDBCException: could not execute query
        at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
        at org.hibernate.loader.Loader.doList(Loader.java:2536)
        at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
        at org.hibernate.loader.Loader.list(Loader.java:2271)
        at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:316)
        at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1842)
        at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
        at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:157)
        at com.vijay.A.main(A.java:24)
    Caused by: java.sql.SQLException: Invalid column name
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:113)
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:147)
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:209)
        at oracle.jdbc.driver.OracleStatement.getColumnIndex(OracleStatement.java:3325)
        at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:1926)
        at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1515)
        at org.hibernate.type.descriptor.sql.VarcharTypeDescriptor$2.doExtract(VarcharTypeDescriptor.java:61)
        at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64)
        at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:254)
        at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:250)
        at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:230)
        at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:331)
        at org.hibernate.loader.Loader.extractKeysFromResultSet(Loader.java:668)
        at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:606)
        at org.hibernate.loader.Loader.doQuery(Loader.java:829)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
        at org.hibernate.loader.Loader.doList(Loader.java:2533)
        ... 7 more
CREATE OR REPLACE PROCEDURE LYCAMONEY.Feeproc1(p_cursor  OUT  sys_refcursor)
as rebate_code1 varchar2(20);
begin

  rebate_code1 := null;
  open p_cursor for
    select REBATE_CODE into rebate_code1  from TRXN_FEE_TABLE;

 dbms_output.put_line(rebate_code1 );

end;
/

Can any one help me out with this issue...... and also post the correct methodology if

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

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

发布评论

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

评论(1

呆° 2024-12-20 05:11:39

好吧,您的存储过程对于初学者来说是错误的。应该是:

open p_cursor for
    select REBATE_CODE from TRXN_FEE_TABLE;

这是错误的,因为 ref 游标是指向查询的指针。它实际上并不获取任何数据。

但我不认为这就是给你带来错误的原因。

Well, your stored procedure is wrong for starters. It should be:

open p_cursor for
    select REBATE_CODE from TRXN_FEE_TABLE;

It's wrong because ref cursor is a pointer to a query. It doesn't actually fetch any data.

But I don't think that is what is giving you the error.

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