Hi Chris,
Can you think of any SQL that will work on your DB that will give you
the results you need? If you can, it should be possible to create an
EclipseLink query that will produce similar SQL. All I can think of is
using a combination of '>' and '<' operators. You would have a pretty
long SQL string, but it should be fairly easy to automate its generation.
Other possibilities:
- Can machine Id be a VARCHAR in the DB?
- Depending on your use case, you might be able to do something complex
with our in memory querying. Something like: Map an additional
read-only mapping to your machineId column with a Converter that
converts it to a String. Read all the possible Machine's into memory
and then execute a checkCacheOnly query for machines with your Like
Expression using our Native API.
-Tom
t3_chris wrote:
Hi!
I am in need to perform a search for some objects which are persited
to my
database and contain Integers and int. The problem is, that i have to
search
for "substrings" within these Numbers.
For example:
Let's assume I've got a Class "Machine" which contains a machineId
(Integer)
and a machineName (String).
There are some Objects stored into the database:
machineId machineName
4711 My Machine 1
8711 My Other Machine
9741 Best Machine
Now i want to do something like this:
Query q = em.createQuery("SELECT m FROM Machine m WHERE m.machineId LIKE
:likeParam");
q.setParameter("likeParam", "%71%");
I want this query to return the machines with the id 4711 and 8711.
How can i achieve this?
Thanks in anticipation!
Best Regards,
chris
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users