Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for startsWith , contains , endsWith for String #29

Closed
georgemoralis opened this issue Jun 30, 2016 · 5 comments
Closed

Support for startsWith , contains , endsWith for String #29

georgemoralis opened this issue Jun 30, 2016 · 5 comments

Comments

@georgemoralis
Copy link

Currently only equals seems to be supported, I guess it is not that hard for the above methods to be added

@my2iu
Copy link
Owner

my2iu commented Jun 30, 2016

That functionality mostly exists, but it's buried in the documentation. You can find it in section "4.2 Functions" of the Query Guide.

@my2iu my2iu closed this as completed Jun 30, 2016
@georgemoralis
Copy link
Author

i am not sure how that works , can you provide me with a small sample pls?

@my2iu
Copy link
Owner

my2iu commented Jul 1, 2016

streams.streamAll(Customer.class)
   .where( c -> c.getName().contains("Jen") )

@georgemoralis
Copy link
Author

yes contains seems to work thanks :) . For startsWith , endWIth i guess there isn't a support since i get

caused by: org.jinq.rebased.org.objectweb.asm.tree.analysis.AnalyzerException: Unknown method java/lang/String:endsWith(Ljava/lang/String;)Z encountered

Is there any plans for that? or i can do it with JPQL.like() ? (but i don't understand how i use that...)

@my2iu
Copy link
Owner

my2iu commented Jul 1, 2016

The underlying database query language of Hibernate/EclipseLink/JPA doesn't have a function that's equivalent to startsWith() and endsWith(), so they aren't directly supported.

If you look at the list of functions that are supported, you can probably construct equivalent functionality using indexOf() and length().

JPQL.like() would also work. You should look up the LIKE function in JPQL or SQL to see what the syntax is. I think it's something like JPQL.like(s, "%th") to see if a string ends in "th".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants