I have table with 2 columns store_number and manager_id and I created an entity and a repository class for the this table.
I'm trying to query manager_id by store_number using repository method below
Bean class:
@Entity public class StoreManagers { @Id @GeneratedValue @Column(name="store_number") private String storeNumber; private String managerId; public StoreManagers() { } public String getStoreNumber() { return storeNumber; } public void setStoreNumber(String storeNumber) { this.storeNumber = storeNumber; } public String getManagerId() { return managerId; } public void setManagerId(String managerId) { this.managerId = managerId; } @Override public String toString() { return "StoreManagers [storeNumber=" + storeNumber + ", manageId=" + managerId + "]"; } } public interface StoreManagersRepository extends JpaRepository<StoreManagers, String> { List<StoreManagers> findByStoreNumber(String storeNumber); } Here is the hibernate query and result
Hibernate: select storemanag0_.manager_discount_id as manager_1_2_, storemanag0_.store_number as store_nu2_2_ from storemanagers storemanag0_ where storemanag0_.store_number=? 2016-12-23 12:16:15.763 TRACE 644 --- [nio-4000-exec-1] o.h.type.descriptor.sql.BasicBinder : binding parameter [1] as [VARCHAR] - [00012] : [] It's returning an empty List, but when I execute above query directly I'm getting results.
Please help me with this. Wat am I doing wrong here?
commitcommand directly and restart your app and check the results. Try printing the query after setting params.