Dain Sundstrom wrote:
On Thursday, February 27, 2003, at 04:14 PM, Curt Johnson wrote:
I'm trying to match the beginning of the column with the parameter value. Shouldn't CONCAT concatenate the parameter and the % character for which then becomes the argument for the LIKE operator? In other words if I had some jboss-ql that was "LIKE CONCAT('abc','def')", shouldn't I expect the SQL to be "LIKE 'abcdef'" rather than "LIKE ('abc' || 'def')"?
No. The JBossQL compiler simply translates.
It seems that I'm having a problem with the resultant query not working properly. That and I was mistaking the string concat op for OR. Doh!
SELECT DISTINCT t0_o.id FROM address t0_o WHERE t0_o.address1 LIKE '?%' OR t0_o.city LIKE '?%' OR t0_o.state LIKE '?%' OR t0_o.country LIKE '?%' OR t0_o.postal_code LIKE '?%'
Does that query work? I would guess it is not legal.
Technically, no it's not legal, I was trying to show my intended result as quickly as possible.
I've seen people using the substring matches, but those make for horrendous SQL debugging.
You can preprocess the arguments to the query and add the '%' to the end of your arguments. Preprocessing arguments is a common task and most people write a home method (instead of a finder) which process the args. For example:
// Home Interface Collection selectSomeStuff(String arg1, ...);
// Bean Implementation public Collection ejbHomeSelectSomeStuff(String arg1, ...) { return ejbSelectSomeStuff(arg1 + "%", ...); } public abstract Collection ejbSelectSomeStuff(String arg1, ...);
Simple?
I think this solution is a decent work-around, I'm using middlegen for the entity beans so it can be a bit difficult to get the code and xdoclet bits merged in right to do things like this. I think I might need a session facade for the default finders in the CMP bean to get the exact results I want. I was hoping to get the logic handled in a finder.
I probably shouldn't be coding on cold medicine either. The issues I'm having seem a lot clearer this morning. Thanks for the pointers.
--Curt
-dain
------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
