-->
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.  [ 2 posts ] 
Author Message
 Post subject: HQL: LIKE - Statement
PostPosted: Thu Feb 16, 2006 4:30 am 
Newbie

Joined: Thu Feb 16, 2006 4:16 am
Posts: 17
Location: Austria
Hallo zusammen!

Ich möchte gerne bei meinem SELECT Statement ein LIKE verwenden und habe dazu das Kapitel 11.4 gelesen:
http://www.hibernate.org/hib_docs/reference/en/html/queryhql.html

Code:
select cat.name from eg.DomesticCat cat
where cat.name like 'fri%'


Jetzt möchte ich aber nicht fix 'fri ...' abfragen sondern einen named-Parameter verwenden.

Code:
select cat.name from eg.DomesticCat cat
where cat.name like ':myParam%'

query.setParameter("myParam", someString);


Leider funktioniert das nicht so wie ich mir das vorstelle. Was muss ich bei dieser Abfrage ändern, damit diese funktioniert?


Vielen Dank für eure Hilfe im Voraus!


MfG
Alexander


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 16, 2006 6:02 am 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
Das ganze funktioniert so...

Code:
select cat.name from eg.DomesticCat cat
where cat.name like :myParam

query.setParameter("myParam", "fri%");


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.