Question

I am trying to compare JCR node's string properties with a double value in JCR-SQL2. But it is comparing the values as strings.

For example:

SELECT * FROM [nodex] as x  where x.propertyY <= 20.50

Here propertyY is the string in the definition.

I tried this with CASE but it still does not work. Can I compare it as double without changing the property definition?

Was it helpful?

Solution

Standard JCR-SQL2 has a CAST(value AS DOUBLE) expression, but unfortunately it can only be used on the right-hand side of an expression. Yes, JCR-SQL2 is not nearly as flexible as normal SQL.

To my knowledge, there is not really a valid standard way to convert the property value to a double before running the comparison. If you cast the double value to a string, you'll get a lexicographical comparison -- which of course won't really be very useful.

I'm not sure about other implementations, but ModeShape would convert the property value to a double when the property is a residual property, since a residual property has no definition and therefore not type. It's quite likely that other implementations would not behave like this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top