cancel
Showing results for 
Search instead for 
Did you mean: 

Facing below issue in Flexible search

mtiwa129
Explorer
0 Kudos

My code :

private static final String Query_EmailAddress_From_B2BUnit = "SELECT {" + DNSB2BUnitPreferencesModel.EMAILADDRESS + "}" + " FROM {" + DNSB2BUnitPreferencesModel._TYPECODE + "}" + " WHERE {" + DNSB2BUnitPreferencesModel.B2BUNIT + "}=?b2bUnit";



@Override public String getEmailAddressesForB2BUnit(final B2BUnitModel b2bUnit) { final FlexibleSearchQuery fQuery = new FlexibleSearchQuery(Query_EmailAddress_From_B2BUnit); fQuery.addQueryParameter("b2bUnit", b2bUnit); final SearchResult<String> result = flexibleSearchService.search(fQuery); final String emailAddressesList = result.getResult().get(0); return emailAddressesList; }

It is giving me search failure because of : Caused by: de.hybris.platform.jalo.flexiblesearch.FlexibleSearchException: SQL search error - Fail to convert to internal representation query = 'SELECT item_t0.p_emailaddress FROM dnsb2bunitpreferences item_t0 WHERE ( item_t0.p_b2bunit =?) AND (item_t0.TypePkString=? )', values = [8806611648517, 8796156788818]

Though in HAC below query is running : select {emailAddress} from {DNSB2BUnitPreferences} where {b2bUnit}='8806611648517'

No idea why it is failing for me , i see no mismatch of types as well

NOTE: Using oracle DB.

Accepted Solutions (0)

Answers (1)

Answers (1)

aimprosoft
Participant

hi Mohit,

please check below the right version of method you are trying to implement:

private static final String query =
        "SELECT {" + DNSB2BUnitPreferencesModel.EMAILADDRESS + "}"
                + " FROM {" + DNSB2BUnitPreferencesModel._TYPECODE + "}"
                + " WHERE {" + DNSB2BUnitPreferencesModel.B2BUNIT + "}=?b2bUnit";

@Override
public String getEmailAddressesForB2BUnit(final B2BUnitModel b2bUnit) {
    final FlexibleSearchQuery fsq = new FlexibleSearchQuery(query);
    fsq.addQueryParameter("b2bUnit", b2bUnit);
    fsq.setResultClassList(Collections.singletonList(String.class));

    final SearchResult<String> searchResult = flexibleSearchService.search(fsq);
    final List<String> result = searchResult.getResult();

    return !result.isEmpty() ? result.get(0) : "";
}

Regards,

Igor