-
1. Re: using character literals in WHERE clause
kv_moj Aug 27, 2003 1:40 AM (in response to akehurst)Hi,
Looks like for the 'a', you need double quotes "a".
So your query generator code would need to change to:
.... phoneContract.contract.endDate and o.approvalCode = \"a\" and .....
Looks like you'd use the single qoutes for numeric constants.
About using java.lang.Character - don't know.
kv. -
2. Re: using character literals in WHERE clause
kv_moj Aug 27, 2003 2:00 AM (in response to akehurst)
BTW - What is the sql/java data type of o.approvalCode ?
I've assumed VARCHAR(n)/java.lang.String for the above. -
3. Re: using character literals in WHERE clause
kv_moj Aug 27, 2003 3:41 AM (in response to akehurst)
Regard to:
Is there a way to specify a char for a comparison against java.lang.Character in ejb-ql?
Here's an extract from standardjbosscmp-jdbc.xml:
<java-type>java.lang.Character</java-type>
<jdbc-type>CHAR</jdbc-type>
<sql-type>CHAR</sql-type>
I'd imagine if you want to make a comparison on a filed in your entity which you've defined as java.lang.Character then you'd use the int value of the char for a literal value as you would the long value of a java.util.Date when using date literals.
If this is the case then you could try:
.... phoneContract.contract.endDate and o.approvalCode = '" + Character.getNumericValue('a')+ "' and ..... -
4. Re: using character literals in WHERE clause
akehurst Aug 27, 2003 9:53 AM (in response to akehurst)>
> Regard to:
>
> Is there a way to specify a char for a comparison
> against java.lang.Character in ejb-ql?
>
> Here's an extract from standardjbosscmp-jdbc.xml:
>
>
> <java-type>java.lang.Character</java-type>
> <jdbc-type>CHAR</jdbc-type>
> <sql-type>CHAR</sql-type>
>
>
> I'd imagine if you want to make a comparison on a
> filed in your entity which you've defined as
> java.lang.Character then you'd use the int value of
> the char for a literal value as you would the long
> value of a java.util.Date when using date literals.
>
> If this is the case then you could try:
>
> .... phoneContract.contract.endDate and
> o.approvalCode = '" + Character.getNumericValue('a')+
> "' and .....
>
We tried using integer value 97 for 'a' and it seems to work. Seems sorta hacky though. Our Ejb-ql is in xdoclet form inside a comment so doing the programmatic way of getting 97 as shown above wouldn't work. Will anyone add char comparisons to jbossql? -
5. Re: using character literals in WHERE clause
akehurst Aug 27, 2003 9:55 AM (in response to akehurst)approvalCode is java.lang.Character
In the database it is type CHAR(1) -
6. Re: using character literals in WHERE clause
kv_moj Aug 27, 2003 12:12 PM (in response to akehurst)
Have you tried all the different permutations of the literal. Such as 'a' , a , "a".
I'd give it a try but I don't have an entity with any Character fields.