Expected number of positional parameters: 1, actual parameters: []

I am getting this below exception when I try to execute a stored procedure using HIbernate from the DaoImpl class. I'm not sure what is wrong. I tried all the ways to fix it but didn't solve the problem. Can anyone help me figure out what is wrong with the code or the mapping file. The more I try to fix it, the more exceptions I get. I am connecting to Oracle 9i DB. I have been struggling to deal with this for 2 weeks, in the end where not. Can anyone help me fix this issue.

Mapping file:

<hibernate-mapping>

    <sql-query name="proc_drsrr_sel_ValDDSummaryBal">
    <!--CALL proc_drsrr_sel_ValDDSummaryBal(:param1)]]>-->
    { call DEFAULT_SCHEMA.proc_name(?,:param1) }

      

Main-Class:

public static void main(String[] args) {
        String procName = "proc_name";// args[0];
        String params = "param1:500089" ;

      

DAO implementation:

@SuppressWarnings("unchecked")
    public void callProc(String procName, Map paramMap) throws SQLException {
        Session session = null;
        Transaction tx = null;
        try {

            session = HibernateUtils.getSessionFactory().getCurrentSession();
            tx = session.beginTransaction();
            String dbURL = session.connection().getMetaData().getURL().toString();
            System.out.println("Conenction DB URL "+ dbURL );
            tx.setTimeout(5);
            String[] keys = new String[paramMap.size()];
            keys = (String[]) paramMap.keySet().toArray(keys);

            Query query = session.getNamedQuery(procName)
            .setParameter("param1", "5501010");

            }

            List result = query.list();
            System.out.println(query.getQueryString());
            for (int i = 0; i < result.size(); i++) {
                // logging the information.
                log.info(i);

            }
            tx.commit();
        } catch (RuntimeException exception) {
            exception.printStackTrace();
            try {
                tx.rollback();
            } catch (RuntimeException rbe) {
                log.error("Couldn’t roll back transaction", rbe);
                rbe.printStackTrace();
            }
            throw exception;
        } finally{   
                   if(session !=null){   
                      session.flush();      
                      session.close();      
            }

      

cfg.xml

<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.url">jdbc:oracle:thin:@ldap://hdsoid.ute.ovi.com:3060/UT1DEV,cn=OracleContext,dc=ute,dc=ovi,dc=com</property>
        <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
        <property name="hibernate.connection.username">nameapp</property>
        <property name="connection.password">nameapp</property>
        <property name="connection.pool_size">1</property>   
        <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
       <!--   <property name="connection.release_mode">after_statement</property> -->
       <property name="default_schema">DEFAULT_SCHEMA</property>

        <property name="current_session_context_class">thread</property>
        <property name="hibernate.show_sql">true</property>
        <!-- mapping files -->
        <mapping resource="com/ovi/domain/hibernate.hbm.xml" />
    </session-factory>
</hibernate-configuration>

      

+3


source to share


1 answer


You will not be able to set a parameter ?

that is so called positional parameter

. Unlike named parameters such as:foo



When you have SQL, you also need to make sure you don't have any Question Marks inside comments! This is what I ran into. The same applies to :

in comments, especially if followed by a space.

+7


source







All Articles