-->
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.  [ 3 posts ] 
Author Message
 Post subject: parameters inside quotes something like --> like ':letter
PostPosted: Mon Aug 09, 2004 10:18 am 
Beginner
Beginner

Joined: Wed Jul 21, 2004 12:28 pm
Posts: 27
Location: New York
Hibernate version: 2.1.4

I need to set parameter of a query that lives inside quotes. The query is:
Code:
from School s where s.schoolName like ':letter%'


I am getting the following exception
Code:
Testsuite: edu.columbia.law.admissions.domain.SystemDictionaryTests
Tests run: 9, Failures: 0, Errors: 1, Time elapsed: 8.031 sec

Testcase: testSchoolsStartingWithALetterListCount(edu.columbia.law.admissions.domain.SystemDictionaryTests):   Caused an ERROR
Parameter letter does not exist as a named parameter in [
            from edu.columbia.law.admissions.domain.School s where s.schoolName like ':letter%'
        ]
java.lang.IllegalArgumentException: Parameter letter does not exist as a named parameter in [
            from edu.columbia.law.admissions.domain.School s where s.schoolName like ':letter%'
        ]
   at net.sf.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:341)
   at net.sf.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:390)
   at edu.columbia.law.admissions.impl.SystemDictionarySpringDAOImpl$7.doInHibernate(SystemDictionarySpringDAOImpl.java:218)
   at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:150)
   at org.springframework.orm.hibernate.HibernateTemplate.executeFind(HibernateTemplate.java:170)
   at edu.columbia.law.admissions.impl.SystemDictionarySpringDAOImpl.listSchools(SystemDictionarySpringDAOImpl.java:212)
   at edu.columbia.law.admissions.domain.SystemDictionaryTests.testSchoolsStartingWithALetterListCount(SystemDictionaryTests.java:100)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at org.apache.commons.jelly.tags.ant.AntTag.doTag(AntTag.java:232)
   at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
   at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
   at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:233)
   at org.apache.commons.jelly.tags.core.IfTag.doTag(IfTag.java:88)
   at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
   at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
   at org.apache.maven.jelly.tags.werkz.MavenGoalTag.runBodyTag(MavenGoalTag.java:79)
   at org.apache.maven.jelly.tags.werkz.MavenGoalTag$MavenGoalAction.performAction(MavenGoalTag.java:110)
   at com.werken.werkz.Goal.fire(Goal.java:639)
   at com.werken.werkz.Goal.attain(Goal.java:575)
   at com.werken.werkz.WerkzProject.attainGoal(WerkzProject.java:193)
   at org.apache.maven.plugin.PluginManager.attainGoals(PluginManager.java:616)
   at org.apache.maven.MavenSession.attainGoals(MavenSession.java:266)
   at org.apache.maven.cli.App.doMain(App.java:486)
   at org.apache.maven.cli.App.main(App.java:1215)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at com.werken.forehead.Forehead.run(Forehead.java:551)
   at com.werken.forehead.Forehead.main(Forehead.java:581)


Are there any alternatives if the above is not possible?

Thanks for your help.

_________________
Thanks,
Alex


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 09, 2004 10:20 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Not possible in Hibernate 2.x, use a bind parameter, not string manipulation.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 09, 2004 10:27 am 
Beginner
Beginner

Joined: Wed Jul 21, 2004 12:28 pm
Posts: 27
Location: New York
thanks for the tip

_________________
Thanks,
Alex


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

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.