db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brendan Miller" <bmil...@dotster.com>
Subject Criteria.addIn on List or Object[] doesn't generate quoted strings?
Date Thu, 06 Mar 2008 23:53:37 GMT

I am trying to use the addIn() method of the Criteria class.

I have a table with various states.  I would like to query objects whose
state is in a list I define.

I have defined my states thusly:

    public enum State { NEW, ACTIVE, SUSPENDED, CANCELED };

I have used both

    crit.addIn(ServicePeer.State, new ArrayList<State> {{
        add(State.NEW);
        add(State.ACTIVE);
    }});

and 

    crit.addIn(ServicePeer.State, { State.NEW, State.ACTIVE });

Both generate SQL as 

SELECT SERVICE.ID, ... FROM SERVICE WHERE SERVICE.STATE IN (NEW,ACTIVE)

Obviously, NEW and ACTIVE need to be quoted.  If I pass a List or array
of Strings, of course it works just fine.  (I know I can get a list or
array of Strings by calling .toString() on my enum values.)

But the documentation says:

Adds an 'IN' clause with the criteria supplied as an Object array. For
example:

FOO.NAME IN ('FOO', 'BAR', 'ZOW')

where 'values' contains three objects that evaluate to the respective
strings above when .toString() is called.


This led me to believe that .toString() would be called internally.  I
guess it is (as I get the string literals in the SQL), but the strings
are not quoted.  Shouldn't they be?

Is this a bug, or am I misreading the documentation?  If it's a bug,
I'd be happy to enter a JIRA and attempt a patch.

Brendan


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message