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: Not All Named Parameters Have Been Set
PostPosted: Wed Jul 19, 2006 8:41 pm 
Beginner
Beginner

Joined: Wed Mar 01, 2006 11:26 pm
Posts: 23
3.0

<?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 default-access="property" default-lazy="false" package="com.pctfiler.web.wizard">

<class name="Question">
<id name="questionId" type="string" />
<property name="questionString" type="string" />
<property name="typeId" type="string" />
<property name="sectionId" type="string" />
<property name="answer" type="string" />
<bag name="definedAnswers">
<key column="answerId" update="false" unique="true" />
<one-to-many class="DefinedAnswer" />
<loader query-ref="NewEstimateQuestions" />
</bag>
</class>

<class name="DefinedAnswer">
<id name="answerId" />
<property name="answerString" />
</class>

<sql-query name="NewEstimateQuestions">
<return alias="ques" class="Question">
<return-property name="questionId" column="QuestionID" />
<return-property name="questionString" column="QuestionText" />
<return-property name="typeId" column="QuestionTypeID" />
<return-property name="sectionId" column="SectionId" />
<return-property name="answerId" column="AnswerID" />
<return-property name="answer" column="AnswerText" />
</return>
<return alias="def" class="DefinedAnswer">
<return-property name="answerString" column="AnswerText" />
</return>
<load-collection alias="cqa" role="Question.definedAnswers" lock-mode="read" />
SELECT q.SectionId, q.QuestionID, q.QuestionText, cqa.AnswerID, a.AnswerText, q.QuestionTypeID FROM prod_cty_sections pcs INNER JOIN sections s ON pcs.SectionID = s.SectionID INNER JOIN questions q ON s.SectionID = q.SectionID LEFT JOIN
closed_question_answers cqa ON q.QuestionID = cqa.QuestionID LEFT JOIN answers a ON cqa.answerID = a.answerID WHERE pcs.countryID IN (:CountryList) AND pcs.ProductId = :ProductId AND s.SectionType = 'FEE' ORDER BY s.SortNumber, q.SortNumber,
cqa.SortNumber
</sql-query>

</hibernate-mapping>


Caused by: org.hibernate.QueryException: Not all named parameters have been set: [CountryList] [SELECT q.SectionId, q.QuestionID, q.QuestionText, cqa.AnswerID, a.AnswerText, q.QuestionTypeID FROM prod_cty_sections pcs INNER JOIN sections s ON pcs.SectionID = s.SectionID INNER JOIN questions q ON s.SectionID = q.SectionID LEFT JOIN
closed_question_answers cqa ON q.QuestionID = cqa.QuestionID LEFT JOIN answers a ON cqa.answerID = a.answerID WHERE pcs.countryID IN (:CountryList) AND pcs.ProductId = :ProductId AND s.SectionType = 'FEE' ORDER BY s.SortNumber, q.SortNumber,
cqa.SortNumber]
at org.hibernate.impl.AbstractQueryImpl.verifyParameters(AbstractQueryImpl.java:284)
at org.hibernate.impl.SQLQueryImpl.verifyParameters(SQLQueryImpl.java:214)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:157)
at org.hibernate.persister.collection.NamedQueryCollectionInitializer.initialize(NamedQueryCollectionInitializer.java:54)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:520)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1695)
at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:454)
at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:828)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:229)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:111)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1674)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:147)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:164)
at com.pctfiler.web.wizard.estimate.factories.NewEstimateQuestionDAO.getQuestions(NewEstimateQuestionDAO.java:65)


MySQL 5.0



Hi there

Im having difficulties executing a query. Im am calling the query shown in the above mapping document "NewEstimateQuestions" and setting the parameters as shown below however an error is thrown telling me that the country list paramter havent been set. If I remove the parameter :ProductId then the query works fine.

Does anyone have any ideads or pointers in this as im totally stumped

Thanks

Chris

Code:
Query query = session.getNamedQuery("NewEstimateQuestions");
            query.setString("ProductId", product.getId());
            query.setParameterList("CountryList", areaMap.keySet());           
            List l = query.list();
            return l;


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.