Sorry I didn't mention in the previous post but I did try that method also and received the same error.
I did try doing this based on another post.
Code:
DetachedCriteria aCriteria = DetachedCriteria.forClass(RecordA.class).add(Restrictions.isNotNull("aprop")).setProjection(Projections.id();
DetachedCriteria bCriteria = DetachedCriteria.forClass(RecordB.class).add(Restrictions.isNotNull("bprop")).setProjection(Projections.id();
DetachedCriteria allCriteria = DetachedCriteria.forClass(Record.class);
allCriteria.add(Restrictions.disjunction().add(Subqueries.eq("this", aCriteria)).add(Subqueries.eq("this", bCriteria)));
List records = allCriteria.getExecutableCriteria(session).list();
This actually gets past the parsing phase and generates the SQL but still doesn't know what to do with the "this".
Exception in thread "main" java.lang.ClassCastException: java.lang.String
at org.hibernate.type.LongType.set(LongType.java:42)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:83)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:65)
at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1514)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1576)
at org.hibernate.loader.Loader.doQuery(Loader.java:661)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:95)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1536)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at us.sotech.test.hibernate.SubqueryTest.main(SubqueryTest.java:32)
2006-04-27 02:57:37,169 [main] DEBUG LongType:80 - binding 'this' to parameter: 1
2006-04-27 02:57:37,169 [main] INFO LongType:87 - could not bind value 'this' to parameter: 1; java.lang.String