I try to make a DAO what needs to search for an item in the database table. I'm pretty new in Hybris so I don't know what is wrong exactly here (query or my junk code). That is the error that appears in cmd.
SEVERE: Servlet.service() for servlet [DispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is de.hybris.platform.servicelayer.search.exceptions.FlexibleSearchException: SQL search error - enable the property 'flexible.search.exception.show.query.details' for more details] with root cause java.sql.SQLException: Invalid value for getLong()
That is my DAO class implementation
@Component(value = "arbRedirectHttpTypeDao")
public class ArbRedirectHttpTypeDaoImpl implements ArbRedirectHttpTypeDao {
private static final Logger LOG = Logger.getLogger(ArbRedirectHttpTypeDaoImpl.class);
@Autowired
private FlexibleSearchService flexibleSearchService;
public FlexibleSearchService getFlexibleSearchService() {
return flexibleSearchService;
}
public void setFlexibleSearchService(FlexibleSearchService flexibleSearchService) {
this.flexibleSearchService = flexibleSearchService;
}
@Override
public ArbRedirectHttpTypeModel findNewUrlByOldUrl(String oldUrl) {
final String query = "SELECT {"+ ArbRedirectHttpTypeModel.NEWURL +"}"
+ " FROM {"+ ArbRedirectHttpTypeModel._TYPECODE +"} WHERE {"
+ ArbRedirectHttpTypeModel.OLDURL +"}=?oldUrl";
final FlexibleSearchQuery flexibleSearchQuery = new FlexibleSearchQuery(query);
flexibleSearchQuery.addQueryParameter("oldUrl", oldUrl);
final List<ArbRedirectHttpTypeModel> locationsByCode = flexibleSearchService
.<ArbRedirectHttpTypeModel> search(flexibleSearchQuery)
.getResult();
LOG.info("-------------------------------------" + locationsByCode.get(0));
if (locationsByCode != null && !locationsByCode.isEmpty())
{
return locationsByCode.get(0);
}
else
{
return null;
}
}
}
And here I try to call it
@Resource
private ArbRedirectHttpTypeDao arbRedirectHttpTypeDao;
ArbRedirectHttpTypeModel arbRedirectHttpTypeModel = arbRedirectHttpTypeDao.findNewUrlByOldUrl("/Aapuvdc");
use "SELECT {"+ ArbRedirectHttpTypeModel.PK +"}". It will return object and you can get all attribute by getter