on 12-03-2014 12:09 PM
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)
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);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just use FlexibleSearchQuery#setResultClassList
with Arrays.asList(String.class)
and the FlexibleSearch will return a List<List<String>>
.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
could you attach your class ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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();
}
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.