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.  [ 6 posts ] 
Author Message
 Post subject: Hibernate Regular Expression Support
PostPosted: Mon Nov 21, 2005 6:54 pm 
Newbie

Joined: Mon Nov 21, 2005 6:06 pm
Posts: 4
Hello Hibernate gurus,

I was wondering if Hibernate offers any support for regular expressions when performing database queries. Specifically, I would like to perform the following...

I have a table in my database that stores contact information and contains a field for a phone number (among other things). Say a user of the system would like to look up the information for a contact using a supplied phone number as the search criteria (e.g. 123-4567, 123.4567, 1234567). I would like to perform a query similar to the following using Hibernate but I am unsure of how to proceed (other than using a direct SQL query):

select * from contacts where phone_number regex '123[^0-9]*4567';

Direct support for regular expressions notwithstanding, is there a way to mimic regular expression support using either the Criteria or Query classes?

Thanks in advance,

Rodney


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 21, 2005 10:34 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
what is your database ?
hibernate support regex if your database support it - if database have exotic operators/functions
(similar oracle's regex_like) then hibernate doesn't support it, but you can add function in dialect


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 22, 2005 10:18 am 
Newbie

Joined: Mon Nov 21, 2005 6:06 pm
Posts: 4
MySQL 5.0 is the database that will be used for this particular project.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 22, 2005 11:07 am 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
i think taht mysql use regex in like clause


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 23, 2005 8:46 am 
Newbie

Joined: Mon Nov 21, 2005 6:06 pm
Posts: 4
Actually, MySQL supports regex in the form of the example listed in the first post (or at least that's the form I'm familiar with if there happens to be more than one).

However, I'm gathering by the responses that Hibernate does not support them nor does it suggest a recommended approach to implement them outside of retrieving a java.sql.Connection and performing a database-specific query.

If I am incorrect in this assumption I would appreciate if someone could point me to a reference that would help clear things up.

Rod


Top
 Profile  
 
 Post subject: Re: Hibernate Regular Expression Support
PostPosted: Thu Feb 25, 2010 1:08 pm 
Beginner
Beginner

Joined: Tue Aug 25, 2009 11:42 am
Posts: 49
http://opensource.atlassian.com/project ... e/HHH-3404


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