-->
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: hql + special chars
PostPosted: Wed May 09, 2007 12:08 pm 
Newbie

Joined: Fri Sep 22, 2006 5:16 am
Posts: 4
Location: Germany
Hi,

ich suche nach einer "Good Practice"-Lösung zum handhaben von "special chars" wie ' oder % in HQL.

Java: Pojo pie, enthält String name
Code:
class pie {
  string name
  ...
}


DB: table pie
Code:
name
---------
Birenenkuchen
Kirschkuchen
Meiner Mutter's besster Apfelkuchen mit 20% Quark


wenn meine Applikation nach Mutter's sucht müsste ich folgendes hql statment dynamisch generieren
Code:

from pie where name like '%Mutter''s%'


Gibt es eine Hibernate Klasse, die mich beim Wandeln String -> HqlString unterstützt?

Danke,
Thomas

_________________
Show me a sane man and I will cure him for you!


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 09, 2007 7:10 pm 
Newbie

Joined: Tue May 08, 2007 4:35 am
Posts: 8
Benutze doch einfach benannte Parameter: http://www.hibernate.org/hib_docs/v3/reference/en/html/objectstate.html#objectstate-querying-executing-parameters


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 9:30 am 
Newbie

Joined: Fri Sep 22, 2006 5:16 am
Posts: 4
Location: Germany
Danke für den Tip, er behebt zwar mein Problem mit dem ' lässt aber das % noch offen.

Nachdem ich eine Oracle DB verwende funktioniert folgendes HQL:

Code:
from pie where name like 'Meiner Mutter''s besster Apfelkuchen mit 20\% Quark' ESCAPE '\'


Wirklich zufieden bin ich damit aber nicht .... :-(

_________________
Show me a sane man and I will cure him for you!


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.