Using Hibernate 2.1.2 here.
Briefly, the object I am querying for is a Document. It has a Metadata object, which contains a HashMap called 'data'. 'data' maps field names to AbstractMetadataValue objects.
The following query works and returns the desired object:
Code:
select d from Document d, AbstractMetadataValue amv where d.Metadata.data['description'] = amv and amv.persistableData like '%desc%'
It gives me the Documents that have a metadata value named 'description' that contains the string 'desc'.
However, the same query does not work within an inner select statement like this:
Code:
select distinct doc from Document doc where doc in (select d from Document d, AbstractMetadataValue amv where d.Metadata.data['description'] = amv and amv.persistableData like '%desc%')
I get the following stack trace, which appears to indicate that this syntax is not supported. Is there a reason why this query does not work? It seems like it ought to.
Quote:
net.sf.hibernate.QueryException: unexpected [ [select distinct doc from collective.mb.asset.Document doc where doc in (select d from collective.mb.asset.Document d, collective.asset.AbstractMetadataValue amv where d.Metadata.data['description'] = amv and amv.persistableData like '%desc%')]
net.sf.hibernate.QueryException: unexpected [ [select distinct doc from collective.mb.asset.Document doc where doc in (select d from collective.mb.asset.Document d, collective.asset.AbstractMetadataValue amv where d.Metadata.data['description'] = amv and amv.persistableData like '%desc%')]
at net.sf.hibernate.hql.WhereParser.token(WhereParser.java:186)
at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
at net.sf.hibernate.hql.PreprocessingParser.token(PreprocessingParser.java:123)
at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:293)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1530)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1501)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1491)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1483)
[/quote][/code]