-->
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: Using Regular expression in entity query - Is it possible??
PostPosted: Thu Oct 08, 2009 11:24 pm 
Newbie

Joined: Tue Nov 25, 2008 9:31 pm
Posts: 18
Hi,

Can we use regular expression in entity query... to remove all non-alphanumeric characters (including whitespace).

I have entity ITEM with ITEM_NAME field...

I can easily achieve this using native sql query as below... but please suggest if there is any quick way aroung using JPA/ Hibernate entity query..

Using SQL:
Code:
select upper(ITEM_NAME) AS ITEM_ORG, upper(regexp_replace(ITEM_NAME, '\W', '')) AS ITEM_FORMATTED from ITEM_TABLE;
[b]Output:[/b]
ITEM_ORG         ITEM_FORMATTED
AAA - BBB    -CC - DDDD      AAABBBCCDDDD

Please suggest.

Regards
Val


Top
 Profile  
 
 Post subject: Re: Using Regular expression in entity query - Is it possible??
PostPosted: Tue Jul 31, 2012 11:57 am 
Newbie

Joined: Thu Sep 14, 2006 12:08 pm
Posts: 19
I have a similar question...

I am using Hibernate Persistence to access a Postegres 9.0 database. Postgres 9.0 support a '~' operator that may be used instead of LIKE to do POSIX regular expression (regexp) matches on string columns if a table. Is there some way that I can use the '~' operator from hibernate persistence EJBQL queries or use the POSIX regexp matching somehow?

Here is a simple example to illustrate what I am looking for:

Query with LIKE (already supported):

Code:
SELECT Object(bar) FROM foo.Bar bar WHERE bar.name LIKE '%acme%';


Query with POSIX RegExp (not supported)
Code:
SELECT Object(bar) FROM foo.Bar bar WHERE bar.name ~ '.*acme.*';


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.