-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add REGEXP support #82
Comments
The custom function feature is mainly intended for stuff like stored procedures. The REGEXP function is a little weird because it’s not standard SQL, but some databases offer it as a built-in function. Because Jinq relies on JPA underneath, you would first need to register the built-in REGEXP function with Hibernate somehow so that Hibernate would know how to deal with it. Then, Jinq would need to be modified to allow REGEXP functions to pass through in a form that Hibernate could handle. Browsing around the web a bit, it looks like it’s potentially doable but a little messy. I don’t currently have the cycles to code on this, but I’ll try to have a deeper look later on. |
I guess I would need to know how you intend on exporting the MySQL REGEXP function so that it's available in Hibernate, then I could see how Jinq could be modified to generate that sort of output. |
So for my specific case i'm using SQLite, this includes support for REGEXP, but does not include an implementation. In my case i supplied my own implementation.
Results in: Running the same through native query: SELECT name FROM MyTable WHERE name REGEXP '^.....$' |
If you want to look further into this then let me know if you need a working sample of the code above |
I think you need something like this to tell Hibernate about regexp before Jinq would be able to do anything (Jinq sits on top of Hibernate and is not able to directly generate any SQL). Performance-wise, I'm not sure you'd be getting much benefit beyond just reading the data into Java, and then filtering by the regex there. I don't think SQLite can do any magic with REGEXes since it bypasses all the database indices and whatnot. |
So based on that link it is possible to add REGEXP support to hibernate without editing the hibernate source code. |
Sure. Once you get the Hibernate side working, you can send me a working Hibernate query that uses REGEXP, and I can then modify Jinq to generate compatible queries. |
I'm trying to add the REGEXP function into jinq.
It's a function from SQLite, has a similar syntax to LIKE.
It should generate:
SELECT name FROM MyTable WHERE name REGEXP '^.....$'
I tried to add REGEXP to custom sql functions, this generated:
"SELECT A FROM MyTable A WHERE function('REGEXP', A.name, :param0)"
Which is not recognized and gives following error:
org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected AST node: function (REGEXP)
I'm assuming that custom sql function may not be correct. Is it possible to add a new AST node for REGEXP function without having to edit the jinq source code?
The text was updated successfully, but these errors were encountered: