@Test public void testUseOfMultipleCustomFieldBridgeInstances() throws Exception { Transaction transaction = fullTextSession.beginTransaction(); final QueryBuilder monthQb = fullTextSession.getSearchFactory().buildQueryBuilder().forEntity(Month.class).get(); // Rather complex code here as we're not exposing the #withFieldBridge methods on the public // interface final ConnectedTermMatchingContext field1Context = (ConnectedTermMatchingContext) monthQb.keyword().onField(MonthClassBridge.FIELD_NAME_1); final ConnectedTermMatchingContext field2Context = (ConnectedTermMatchingContext) field1Context .withFieldBridge(new String2FieldBridgeAdaptor(new RomanNumberFieldBridge())) .andField(MonthClassBridge.FIELD_NAME_2); Query query = field2Context .withFieldBridge(new String2FieldBridgeAdaptor(new RomanNumberFieldBridge())) .matching(2) .createQuery(); assertEquals(1, fullTextSession.createFullTextQuery(query, Month.class).getResultSize()); transaction.commit(); }
@Test public void testUseOfCustomFieldBridgeInstance() throws Exception { Transaction transaction = fullTextSession.beginTransaction(); final QueryBuilder monthQb = fullTextSession.getSearchFactory().buildQueryBuilder().forEntity(Month.class).get(); ConnectedTermMatchingContext termMatchingContext = (ConnectedTermMatchingContext) monthQb.keyword().onField(MonthClassBridge.FIELD_NAME_1); Query query = termMatchingContext .withFieldBridge(new String2FieldBridgeAdaptor(new RomanNumberFieldBridge())) .matching(2) .createQuery(); assertEquals(1, fullTextSession.createFullTextQuery(query, Month.class).getResultSize()); transaction.commit(); }