cancel
Showing results for 
Search instead for 
Did you mean: 

Invalid value getLong() when executing flexible search query from code

Former Member

Hi, I am having a problem with a simple query, it executes successfully in the hybris console but fails from code, with Invalid value getLong() error.

SELECT DISTINCT {p.name} FROM {Publication! AS p} ORDER BY {p.name} ASC

Invalid value for getLong() - 'Beeld' query = 'SELECT DISTINCT lp_t0.p_name FROM publicationlp lp_t0 WHERE ((lp_t0.LANGPK =? )) AND (lp_t0.ITEMTYPEPK=? ) order by lp_t0.p_name ASC', values = [8796093055008, 8796098396242]] with root cause java.sql.SQLException: Invalid value for getLong() - 'Beeld' at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Well you are returning non hybris model in your flexi query & by default the flexisearch query always trys to cast the return to PK of hybris item

if you really want to return non hybris item type in flexi search query then you need to set the return data types as below….
FlexibleSearchQuery.setResultClassList(resultClassList);

Answers (3)

Answers (3)

tino_kissig
Active Participant
0 Kudos

Just use FlexibleSearchQuery#setResultClassList with Arrays.asList(String.class) and the FlexibleSearch will return a List<List<String>>.

Former Member
0 Kudos

Hi, You have to select only the PK, and after getting your model as result you can get the name and code from it. SELECT DISTINCT {p.PK} FROM {Publication! AS p} ORDER BY {p.name} ASC

Former Member
0 Kudos

could you attach your class ?

Former Member
0 Kudos

here is the relevent part of the class, it executes this method

..... private FlexibleSearchService flexibleSearchService;

..... @Override public List getPublicationList() {

     String queryBuffer = "SELECT DISTINCT {p.name},{p.code} 
            FROM {
                               Publication! AS p}  ORDER BY {p.name} ASC";
     FlexibleSearchQuery query = new FlexibleSearchQuery(queryBuffer);
     SearchResult<PublicationModel> searchResult = 
      flexibleSearchService.search(query);
     return searchResult.getResult();
 }