users@glassfish.java.net

Re: EJBQL Question

From: <glassfish_at_javadesktop.org>
Date: Wed, 16 May 2007 13:22:14 PDT

If it's not possible to write SQL that will get the results you want, JPQL will likely not help you. It does not have the concept of invoking methods as part of the query and is really quite closely tied to SQL.

I have some suggestions although I suspect none of them are ideal

1. 2 queries

select object(value) from ValueString value where value.value like :param
select object(value) from ValueInt value where value.value > :param1 and value.value < param2

Depending on the complexity of your regular expression, it should be possible to construct a where clause that can handle the ints using comparison operators

2. Map a dummy column to contain your computed asString and then query on that column. The getter and setter methods could do the necessary computations.

All of this, of course, depends on getting the inheritance hierarchy correctly dealing with the fields you are interested in. I suspect you will have to be quite careful with the mappings to have two separate subclasses with different mappings that use an instance variable of the same name but map to different DB fields (I assume)
[Message sent by forum member 'tware' (tware)]

http://forums.java.net/jive/thread.jspa?messageID=217476