public void popularity(ShopRoomTarriffCorporateRateView item) { ShopRoomTarriffCorporateRateView shoproomtarriffcorporaterateview = null; if (item != null) { shoproomtarriffcorporaterateview = findById(item.getId(), false); } if (shoproomtarriffcorporaterateview != null) { if (SObject.class.isAssignableFrom(ShopRoomTarriffCorporateRateView.class)) { if (shoproomtarriffcorporaterateview.getPopularity() == null) { shoproomtarriffcorporaterateview.setPopularity(-1); } shoproomtarriffcorporaterateview.setPopularity( shoproomtarriffcorporaterateview.getPopularity() + 1); try { em.createNativeQuery( String.format(updatePopularityClause, tableName), ShopRoomTarriffCorporateRateView.class) .setParameter("popularity", shoproomtarriffcorporaterateview.getPopularity()) .setParameter("id", item.getId()) .executeUpdate(); } catch (Exception e) { e.printStackTrace(); } } } }