You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Patrick Linskey <pl...@gmail.com> on 2010/02/13 02:12:05 UTC

Question about JPQLExpressionBuilder.getTypeLiteral()

Hi,

I'm working on adding support for queries against a non-relational  
store, and I've run into an issue with the new JPA2 type literal stuff.

I'm compiling a query such as the following:

	select s from Skier s where type(s) = Skier

My target database doesn't support joins, so in my ExpressionFactory  
implementation, I throw exceptions whenever join-ish things are done.

I'm getting into trouble because  
JPQLExpressionBuilder.getTypeLiteral() calls getVariable(), which ends  
up calling ExpressionFactory.newUnboundVariable() eventually. Which  
blows up.

Now, I could change my implementation to not throw in  
newUnboundVariable(), but I feel like a type literal isn't a variable.  
Was there some larger bit of rationale behind making getTypeLiteral()  
return an unbound variable, or should I feel free to dig into changing  
it to return a more suitable type?

(Incidentally, I've got things working with type parameters (i.e.,  
'where type(s) = :type'), so the pathways seem to be great aside from  
this variable discrepancy.)

Thanks,

-Patrick

-- 
Patrick Linskey
202 669 5907


Re: Question about JPQLExpressionBuilder.getTypeLiteral()

Posted by Patrick Linskey <pl...@gmail.com>.
Digging into this further, it looks like the getVariable() call is  
relatively unused. Maybe it's just a validation check? If so, what's  
it validating? Do we support path traversals etc. in type comparisons,  
or just comparisons to parameters and literals?

Thanks,

-Patrick

On Feb 12, 2010, at 5:12 PM, Patrick Linskey wrote:

> Hi,
>
> I'm working on adding support for queries against a non-relational  
> store, and I've run into an issue with the new JPA2 type literal  
> stuff.
>
> I'm compiling a query such as the following:
>
> 	select s from Skier s where type(s) = Skier
>
> My target database doesn't support joins, so in my ExpressionFactory  
> implementation, I throw exceptions whenever join-ish things are done.
>
> I'm getting into trouble because  
> JPQLExpressionBuilder.getTypeLiteral() calls getVariable(), which  
> ends up calling ExpressionFactory.newUnboundVariable() eventually.  
> Which blows up.
>
> Now, I could change my implementation to not throw in  
> newUnboundVariable(), but I feel like a type literal isn't a  
> variable. Was there some larger bit of rationale behind making  
> getTypeLiteral() return an unbound variable, or should I feel free  
> to dig into changing it to return a more suitable type?
>
> (Incidentally, I've got things working with type parameters (i.e.,  
> 'where type(s) = :type'), so the pathways seem to be great aside  
> from this variable discrepancy.)
>
> Thanks,
>
> -Patrick
>
> -- 
> Patrick Linskey
> 202 669 5907
>

-- 
Patrick Linskey
202 669 5907