|
I have two composite keys represented by following classes: UserAccessAreaId consisting of 'accessAreaId' and 'userId' fields ReportAccessAreaId consisting of 'accessAreaId' and 'reportId' fields
I have then created two classes implementing TwoWayFieldBridge for these classes. Both these bridge classes creates a field named 'id.accessAreaId'.
I perform a search after successful indexing:
FullTextSession fullTextSession = Search
.getFullTextSession(sessionFactory.getCurrentSession());
QueryBuilder qb = fullTextSession.getSearchFactory()
.buildQueryBuilder().forEntity(ReportAccessArea.class).get();
Query luceneQuery = qb.keyword().onField("id.accessAreaId").ignoreFieldBridge().matching(198).createQuery();
FullTextQuery fullTextQuery = fullTextSession
.createFullTextQuery(luceneQuery);
fullTextQuery.setProjection("id");
fullTextQuery.setResultTransformer(new AliasToBeanResultTransformer(
ReportAccessArea.class));
List<ReportAccessArea> list = fullTextQuery.list();
Then I get an unexpected problem:
It seems like it is fetching and trying to set an UserAccessAreaId when it should have been a ReportAccessAreaId instead.
If I change the naming of the field 'id.accessAreaId' in the ReportAccessAreaId class to 'id.aaccessAreaId' and search using that field name instead, I get no problem.
To me it looks like a problem in Hibernate Search since I can't currently see that I am causing this problem, but on the other hand I'm quite new to Hibernate Search.
|