sqljcrmagnoliajcr-sql2

JCR-SQL2 Query Subnodes


I need to find an entry in the JCR where a Date in a list of nodes containing dates matches my criteria. Data Structure is

- Event1 -- Dates --- 0 ---- startDate: xyz ---- endDate: xyz --- 1 ---- startDate: xyz ---- endDate: xyz - Event1 -- Dates --- 0 ---- startDate: xyz ---- endDate: xyz --- 1 ---- startDate: xyz ---- endDate: xyz

Data Structure

So I need iterate over all Nodes and now I need to select the subnode called DATE and iterate over that and check the timestamp prop. If the timestamp matches my criterium, then return the whole node.

here's a failed attempt:

select p.date from [mgnl:contact] as p where p.[startDate] > CAST('2010-01-01T00:00:00.000+02:00' as date)

which i was hoping to fetch me all entries after jan 1. 2010.

I could do this by just grabbing everything from the jcr and doing this filtering in Java. In JCR-SQL2, I don't even know where to start.


Solution

  • I guess it doesn't work because p.date is not direct property of the given node type. I assume it'd work if you change it to mgnl:contentNode.

    Also give this a shot:

    select * from [mgnl:contact] where [startDate] > cast('2010-01-01T00:00:00.000+02:00' as date)

    Cheers,

    HTH,