gpt4 book ai didi

java - 我收到错误 "Invalid column name"

转载 作者:行者123 更新时间:2023-12-01 15:41:34 25 4
gpt4 key购买 nike

<?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;
/

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

最佳答案

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

open p_cursor for
select REBATE_CODE from TRXN_FEE_TABLE;

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

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

关于java - 我收到错误 "Invalid column name",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7964201/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com