You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Adrian Wiesmann <aw...@somap.org> on 2010/09/27 12:27:26 UTC

Expression.filter and UUIDs

Hello all

We are working with Expression.fromString() where we have something like
this:

'propertyXY = "b1db2da8-9630-4d55-a1bb-10f26dd085bb"'

Unfortunately this does not work since the getter on the DataObject
returns a UUID while the Expression recognises the UUID as a string.
Comparing a UUID with a string does not work (well it does, but the result
is not as wanted :) )

So here is my question. How can we solve this problem? Are we the only
ones encountering that problem?

Thanks for your help,
Adrian



Re: Expression.filter and UUIDs

Posted by Andrey Razumovsky <ra...@gmail.com>.
2010/9/27 Andrus Adamchik <an...@objectstyle.org>

> 2. Take a look at
> framework/cayenne-jdk1.5-unpublished//src/main/jjtree/org/apache/cayenne/exp/parser/ExpressionParser.jjt
> This is a JavaCC (specifically - JJTree) grammar of the Cayenne expression
> language.
> 3. Add support for "constructor expression" syntax to the grammar.
>


IIRC JJTree-parser already supports constructors. So we only need to
implement processing
-- 
Andrey

Re: Expression.filter and UUIDs

Posted by Andrus Adamchik <an...@objectstyle.org>.
On Sep 27, 2010, at 3:06 PM, Adrian Wiesmann wrote:

>> 
>> Or we can work together on supporting constructors in Expressions, similar
>> to how JPQL does:
>> 
>>   propertyXY = new java.util.UUID(1, 2)
> 
> I'd be willing to work on this. How can we proceed with that?

Cool. We may continue this discussion on the dev list. Let me start here by giving some pointers:

1. Get Cayenne code (3.0 or 3.1) 
2. Take a look at framework/cayenne-jdk1.5-unpublished//src/main/jjtree/org/apache/cayenne/exp/parser/ExpressionParser.jjt This is a JavaCC (specifically - JJTree) grammar of the Cayenne expression language.
3. Add support for "constructor expression" syntax to the grammar.
4. Implement processing of constructors in QualifierTranslator and for in-mempry evaluation
5. Create unit tests (likely add more test cases to the existing expression and SelectQuery tests)
6. Submit a patch.

BTW, checked the JPQL spec, and they only allow constructor in the "SELECT" clause. The above will support it in the WHERE clause, which is nice. We will also port that to EJBQLQuery at some point as well. 

Andrus


Re: Expression.filter and UUIDs

Posted by Adrian Wiesmann <aw...@somap.org>.
> There's no parsable notation for UUID. So you can either use API to
> assemble expressions, or use a parameter bound via API at a later time:
>
>    propertyXY = $x

Thats the way we do it for now. Thanks for the hint.


> Or we can work together on supporting constructors in Expressions, similar
> to how JPQL does:
>
>    propertyXY = new java.util.UUID(1, 2)

I'd be willing to work on this. How can we proceed with that?

Adrian



Re: Expression.filter and UUIDs

Posted by Andrus Adamchik <an...@objectstyle.org>.
There's no parsable notation for UUID. So you can either use API to assemble expressions, or use a parameter bound via API at a later time:

   propertyXY = $x

Or we can work together on supporting constructors in Expressions, similar to how JPQL does:

   propertyXY = new java.util.UUID(1, 2)

Andrus

On Sep 27, 2010, at 1:27 PM, Adrian Wiesmann wrote:

> Hello all
> 
> We are working with Expression.fromString() where we have something like
> this:
> 
> 'propertyXY = "b1db2da8-9630-4d55-a1bb-10f26dd085bb"'
> 
> Unfortunately this does not work since the getter on the DataObject
> returns a UUID while the Expression recognises the UUID as a string.
> Comparing a UUID with a string does not work (well it does, but the result
> is not as wanted :) )
> 
> So here is my question. How can we solve this problem? Are we the only
> ones encountering that problem?
> 
> Thanks for your help,
> Adrian
> 
> 
>