-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Cannot Dereference Scalar Collection
PostPosted: Mon May 16, 2005 11:59 am 
Beginner
Beginner

Joined: Mon Oct 11, 2004 12:30 pm
Posts: 21
I'm trying to do a simple query in a unit test as follows:
Code:
   public void testQueryByInput() throws Exception {
      List keys = new ArrayList();
      List values = new ArrayList();
      keys.add("FirmName");
      values.add("Protege Holdings");
      List checks = dao.getChecksByInputParams(keys, values);
      assertTrue("Should have two checks with protege holdings as the firm name", checks.size()==2);
      
   }


This query hits a mapped table KYCINPUT to find the foreign keys referenced to the main table (as you can see in the mapping file below). I am getting the following exception, and I'm not sure how to resolve it.

Code:
Testcase: testQueryByInput(com.semagix.ciras.model.dao.KYCCheckDAOTest):        Caused an ERROR
cannot dereference scalar collection element: key [from com.semagix.ciras.model.KYCCheck check where check.input.key in (:keys0_) and check.input.value in (:values0_)]; nested exception is org.hibernate.QueryException: cannot dereference scalar collection element: key [from com.semagix.ciras.model.KYCCheck check where check.input.key in (:keys0_) and check.input.value in (:values0_)]


Any Pointers would be much appreciated.
Jason

Hibernate version:
3.0.1

Mapping documents:
Code:
<?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.semagix.ciras.model.KYCCheck" table="KYCCHECK" discriminator-value="100">
   
    <id name="id" column="ID" unsaved-value="0">
      <generator class="identity"/>
    </id>
   
    <discriminator type="integer" not-null="true" column="CHECKTYPE"/>
   
    <timestamp name="timestamp" column="TIMESTAMP"/>
   
    <set name="history" order-by="id" table="KYCCHECKINFO" lazy="false" cascade="all">
      <key column="CHECK_ID" not-null="true"/>
      <one-to-many class="com.semagix.ciras.model.KYCCheckInfo"/>
    </set>
   
    <map name="results" table="QUERY_RESULT" order-by="QSCOMPONENT_ID asc" lazy="false">
      <key column="CHECK_ID"/>
      <map-key-many-to-many column="QSCOMPONENT_ID" class="com.semagix.ciras.model.QsComponent"/>
      <element type="string" column="RESULT"/>
    </map>
   
    <map name="scores" table="KYCSCORE" order-by="QSCOMPONENT_ID asc" lazy="false">
      <key column="CHECK_ID"/>
      <map-key-many-to-many column="QSCOMPONENT_ID" class="com.semagix.ciras.model.QsComponent"/>
      <composite-element class="com.semagix.ciras.model.KYCScore">
        <property name="value" column="VALUE"/>
        <property name="description" column="DESCRIPTION"/>
      </composite-element>
    </map>
   
    <map name="input" table="KYCINPUT" lazy="false">
      <key column="CHECK_ID" />
      <map-key column="PARAM" type="string" length="255"/>
      <element column="VALUE" type="string" length="2000"/>
    </map>
       
  </class>
   
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
using spring
Code:
public List getChecksByInputParams(List keys, List values) {
      return getHibernateTemplate()
            .findByNamedParam("from KYCCheck check where check.input.key in (:keys) and check.input.value in (:values)",
                  new String [] { "keys", "values"},
                  new Object [] { keys, values});
      
   }


Full stack trace of any exception that occurs:
Code:
Testcase: testQueryByInput(com.semagix.ciras.model.dao.KYCCheckDAOTest):        Caused an ERROR
cannot dereference scalar collection element: key [from com.semagix.ciras.model.KYCCheck check where check.input.key in (:keys0_) and check.input.value in (:values0_)]; nested exception is org.hibernate.QueryException: cannot dereference scalar collection element: key [from com.semagix.ciras.model.KYCCheck check where check.input.key in (:keys0_) and check.input.value in (:values0_)]
org.springframework.orm.hibernate3.HibernateQueryException: cannot dereference scalar collection element: key [from com.semagix.ciras.model.KYCCheck check where check.input.key in (:keys0_) and check.input.value in (:values0_)]; nested exception is org.hibernate.QueryException: cannot dereference scalar collection element: key [from com.semagix.ciras.model.KYCCheck check where check.input.key in (:keys0_) and check.input.value in (:values0_)]
org.hibernate.QueryException: cannot dereference scalar collection element: key [from com.semagix.ciras.model.KYCCheck check where check.input.key in (:keys0_) and check.input.value in (:values0_)]
        at org.hibernate.persister.collection.ElementPropertyMapping.toType(ElementPropertyMapping.java:33)
        at org.hibernate.persister.collection.AbstractCollectionPersister.toType(AbstractCollectionPersister.java:1090)
        at org.hibernate.hql.ast.FromElementType.getPropertyType(FromElementType.java:231)
        at org.hibernate.hql.ast.FromElement.getPropertyType(FromElement.java:342)
        at org.hibernate.hql.ast.DotNode.getDataType(DotNode.java:474)
        at org.hibernate.hql.ast.DotNode.prepareLhs(DotNode.java:208)
        at org.hibernate.hql.ast.DotNode.resolve(DotNode.java:166)
        at org.hibernate.hql.ast.FromReferenceNode.resolve(FromReferenceNode.java:87)
        at org.hibernate.hql.ast.FromReferenceNode.resolve(FromReferenceNode.java:83)
        at org.hibernate.hql.ast.HqlSqlWalker.resolve(HqlSqlWalker.java:463)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:861)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.inLhs(HqlSqlBaseWalker.java:3797)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3498)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1399)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1324)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:599)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:404)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:201)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:151)
        at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)
        at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130)
        at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
        at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:421)
        at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:824)
        at org.hibernate.impl.SessionImpl.list(SessionImpl.java:782)
        at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)



Name and version of the database you are using:
$ mysql --version
mysql Ver 14.7 Distrib 4.1.11, for pc-linux-gnu (i686)

The generated SQL (show_sql=true):
Never gets there


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.