org.hibernate.QueryException: addEntity() or addScalar() must be called on a sql query before executing the query. [from com.marsh.cansys.clt.services.client.business.ClientAddressUsageBO c where c.cltNo = 747776 and c.cltOfcNo=3 and c.cltAddType='PRI' and c.cltAddKey=262050]

Hibernate JIRA | chaitanya sanjay karmarakr | 1 decade ago
  1. 0

    This is my mapping file: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="com.marsh.cansys.clt.services.client.business.ClientAddressUsageBO" table="CLIENT.CLT_ADD_USG"> <composite-id> <key-property name="cltNo" length="10" column="CLT_NO"/> <key-property name="cltOfcNo" length="10" column="CLT_OFC_NO" type="integer"/> <key-property name="cltAddKey" length="10" column="CLT_ADD_KEY" type="long"/> <key-property name="cltAddType" length="3" column="CLT_ADD_TYPE"/> </composite-id> <!-- property name="cltNo" type="long"> <column name="CLT_NO"/> </property> <property name="cltOfcNo" type="long"> <column name="CLT_OFC_NO"/> </property> <property name="cltAddKey" type="long"> <column name="CLT_ADD_KEY"/> </property> <property name="cltAddType"> <column name="CLT_ADD_TYPE"/> </property--> <property name="cltAdrLuby" type="long"> <column name="CLT_ADD_LUBY"/> </property> <property name="cltAdrLudt" type="calendar_date"> <column name="CLT_ADR_LUDT"/> </property> <property name="syncManageCustomer"> <column name="SYNC_MANAGE_CUSTOMER_FG"/> </property> <!-- one-to-one name="clientAddress" class="com.marsh.cansys.clt.services.client.business.ClientAddressBO" cascade="all"/--> <!-- property name="clientAddress" type="java.lang.Object" access="com.marsh.cansys.clt.services.client.business.ClientAddressBO"/--> </class> </hibernate-mapping> This is my DAO: /* * Created on Dec 6, 2005 */ package com.marsh.cansys.ams.address.DAO; import java.util.List; import org.hibernate.Query; import org.hibernate.SQLQuery; import org.hibernate.Session; import org.hibernate.Transaction; import com.marsh.cansys.ams.dataaccess.HibernateSessionFactory; import com.marsh.cansys.clt.services.client.business.ClientAddressUsageBO; import com.marsh.cansys.clt.services.client.business.ClientAddressUsageBOIF; public class AddressDAO { Session session; public ClientAddressUsageBOIF getClientAddress() { Integer cltNo = new Integer("747776"); Integer cltOfcNo = new Integer("3"); getConnection(); Transaction tx = session.beginTransaction(); Query q = session.createQuery( "from com.marsh.cansys.clt.services.client.business.ClientAddressUsageBO c");// where c.cltNo = 747776 and c.cltOfcNo=3 and c.cltAddType='PRI' and c.cltAddKey=262050"); // "select c.syncManageCustomer from // com.marsh.cansys.clt.services.client.business.ClientAddressUsageBO c // where c.cltNo = 747776"); // List result = session.createQuery // ("from // com.marsh.cansys.clt.services.client.business.ClientAddressUsageBO c // where c.cltNo = 747776 and c.cltOfcNo = 3") // .setInteger(0, 7467776) // .setInteger(1, 3) // .list(); List result = q.list(); // ClientAddressUsageBOIF addressUsageBO = (ClientAddressUsageBO) tx.commit(); HibernateSessionFactory.closeSession(); return null; } public void getConnection() { try { session = HibernateSessionFactory.currentSession(); } catch (Exception e) { System.out.println("Hibernation error"); e.printStackTrace(); } } } When I fire the above query I am getting the following stackTrace org.hibernate.QueryException: addEntity() or addScalar() must be called on a sql query before executing the query. [from com.marsh.cansys.clt.services.client.business.ClientAddressUsageBO c where c.cltNo = 747776 and c.cltOfcNo=3 and c.cltAddType='PRI' and c.cltAddKey=262050] at org.hibernate.impl.SQLQueryImpl.verifyParameters(SQLQueryImpl.java:169) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:140) at com.marsh.cansys.ams.address.DAO.AddressDAO.getClientAddress(AddressDAO.java:44) at com.marsh.cansys.clt.services.client.controller.AddressControllerImpl.getClientAddress(AddressControllerImpl.java:32) at com.marsh.cansys.clt.services.client.controller.AddressControllerImpl.main(AddressControllerImpl.java:25) Exception in thread "main" Why am I getting this exception...Please help.

    Hibernate JIRA | 1 decade ago | chaitanya sanjay karmarakr
    org.hibernate.QueryException: addEntity() or addScalar() must be called on a sql query before executing the query. [from com.marsh.cansys.clt.services.client.business.ClientAddressUsageBO c where c.cltNo = 747776 and c.cltOfcNo=3 and c.cltAddType='PRI' and c.cltAddKey=262050]
  2. 0

    This is my mapping file: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="com.marsh.cansys.clt.services.client.business.ClientAddressUsageBO" table="CLIENT.CLT_ADD_USG"> <composite-id> <key-property name="cltNo" length="10" column="CLT_NO"/> <key-property name="cltOfcNo" length="10" column="CLT_OFC_NO" type="integer"/> <key-property name="cltAddKey" length="10" column="CLT_ADD_KEY" type="long"/> <key-property name="cltAddType" length="3" column="CLT_ADD_TYPE"/> </composite-id> <!-- property name="cltNo" type="long"> <column name="CLT_NO"/> </property> <property name="cltOfcNo" type="long"> <column name="CLT_OFC_NO"/> </property> <property name="cltAddKey" type="long"> <column name="CLT_ADD_KEY"/> </property> <property name="cltAddType"> <column name="CLT_ADD_TYPE"/> </property--> <property name="cltAdrLuby" type="long"> <column name="CLT_ADD_LUBY"/> </property> <property name="cltAdrLudt" type="calendar_date"> <column name="CLT_ADR_LUDT"/> </property> <property name="syncManageCustomer"> <column name="SYNC_MANAGE_CUSTOMER_FG"/> </property> <!-- one-to-one name="clientAddress" class="com.marsh.cansys.clt.services.client.business.ClientAddressBO" cascade="all"/--> <!-- property name="clientAddress" type="java.lang.Object" access="com.marsh.cansys.clt.services.client.business.ClientAddressBO"/--> </class> </hibernate-mapping> This is my DAO: /* * Created on Dec 6, 2005 */ package com.marsh.cansys.ams.address.DAO; import java.util.List; import org.hibernate.Query; import org.hibernate.SQLQuery; import org.hibernate.Session; import org.hibernate.Transaction; import com.marsh.cansys.ams.dataaccess.HibernateSessionFactory; import com.marsh.cansys.clt.services.client.business.ClientAddressUsageBO; import com.marsh.cansys.clt.services.client.business.ClientAddressUsageBOIF; public class AddressDAO { Session session; public ClientAddressUsageBOIF getClientAddress() { Integer cltNo = new Integer("747776"); Integer cltOfcNo = new Integer("3"); getConnection(); Transaction tx = session.beginTransaction(); Query q = session.createQuery( "from com.marsh.cansys.clt.services.client.business.ClientAddressUsageBO c");// where c.cltNo = 747776 and c.cltOfcNo=3 and c.cltAddType='PRI' and c.cltAddKey=262050"); // "select c.syncManageCustomer from // com.marsh.cansys.clt.services.client.business.ClientAddressUsageBO c // where c.cltNo = 747776"); // List result = session.createQuery // ("from // com.marsh.cansys.clt.services.client.business.ClientAddressUsageBO c // where c.cltNo = 747776 and c.cltOfcNo = 3") // .setInteger(0, 7467776) // .setInteger(1, 3) // .list(); List result = q.list(); // ClientAddressUsageBOIF addressUsageBO = (ClientAddressUsageBO) tx.commit(); HibernateSessionFactory.closeSession(); return null; } public void getConnection() { try { session = HibernateSessionFactory.currentSession(); } catch (Exception e) { System.out.println("Hibernation error"); e.printStackTrace(); } } } When I fire the above query I am getting the following stackTrace org.hibernate.QueryException: addEntity() or addScalar() must be called on a sql query before executing the query. [from com.marsh.cansys.clt.services.client.business.ClientAddressUsageBO c where c.cltNo = 747776 and c.cltOfcNo=3 and c.cltAddType='PRI' and c.cltAddKey=262050] at org.hibernate.impl.SQLQueryImpl.verifyParameters(SQLQueryImpl.java:169) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:140) at com.marsh.cansys.ams.address.DAO.AddressDAO.getClientAddress(AddressDAO.java:44) at com.marsh.cansys.clt.services.client.controller.AddressControllerImpl.getClientAddress(AddressControllerImpl.java:32) at com.marsh.cansys.clt.services.client.controller.AddressControllerImpl.main(AddressControllerImpl.java:25) Exception in thread "main" Why am I getting this exception...Please help.

    Hibernate JIRA | 1 decade ago | chaitanya sanjay karmarakr
    org.hibernate.QueryException: addEntity() or addScalar() must be called on a sql query before executing the query. [from com.marsh.cansys.clt.services.client.business.ClientAddressUsageBO c where c.cltNo = 747776 and c.cltOfcNo=3 and c.cltAddType='PRI' and c.cltAddKey=262050]
  3. 0

    Retrieving a value from Stored Procedure using Native SQL Hibernate

    Stack Overflow | 3 years ago | user182944
    org.hibernate.QueryException: Expected positional parameter count: 1, actual parameters: [] [CALL proc_empname_refcursor(?, :deptId)] at org.hibernate.impl.AbstractQueryImpl.verifyParameters(AbstractQueryImpl.java:319)
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    org.hibernate.QueryException: Expected positional parameter

    Stack Overflow | 4 years ago | JNPW
    org.hibernate.QueryException: Expected positional parameter count: 2, actual parameters: [[7, ABC]] [select * from PMT.CSE_NME_VW where PMT_ID=? and PMT_NAME=?]
  6. 0

    Org.hibernate.QueryException: Expected positional parameter - scriptscoop.com

    scriptscoop.com | 1 year ago
    org.hibernate.QueryException: Expected positional parameter count: 2, actual parameters: [[7, ABC]] [select * from PMT.CSE_NME_VW where PMT_ID=? and PMT_NAME=?]

    1 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.hibernate.QueryException

      addEntity() or addScalar() must be called on a sql query before executing the query. [from com.marsh.cansys.clt.services.client.business.ClientAddressUsageBO c where c.cltNo = 747776 and c.cltOfcNo=3 and c.cltAddType='PRI' and c.cltAddKey=262050]

      at org.hibernate.impl.SQLQueryImpl.verifyParameters()
    2. Hibernate
      SQLQueryImpl.list
      1. org.hibernate.impl.SQLQueryImpl.verifyParameters(SQLQueryImpl.java:169)
      2. org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:140)
      2 frames
    3. com.marsh.cansys
      AddressControllerImpl.main
      1. com.marsh.cansys.ams.address.DAO.AddressDAO.getClientAddress(AddressDAO.java:44)
      2. com.marsh.cansys.clt.services.client.controller.AddressControllerImpl.getClientAddress(AddressControllerImpl.java:32)
      3. com.marsh.cansys.clt.services.client.controller.AddressControllerImpl.main(AddressControllerImpl.java:25)
      3 frames