org.hibernate.QueryException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • 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.
    via by chaitanya sanjay karmarakr,
  • 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.
    via by chaitanya sanjay karmarakr,
  • MS SQL server bind variables
    via by Gina vernon,
    • 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)

    Users with the same issue

    Unknown visitor
    Unknown visitor1 times, last one,