Error:"Non-static method 'findByIasId(java.lang.String)' cannot be referenced from a static context "
I am trying to check if iasId exist in Mapping table or not if it exist then it will return the corresponding orgId of given iasId from mapping Table. None of these(iasId and orgId) is Pk of mapping table.
So I am writig a function in Repository class for finding this iasId but I am getting error "Non-static method 'findByOasPatientId(java.lang.String)' cannot be referenced from a static context"
Mapping updateUser = MappingRepository.findByIasId(iasId);// This function is giving error which is supposed to find the given IASID in table.
Within Update Service Class
private String getOrgID(String iasId) {
Mapping updateUser = MappingRepository.findByIasId(iasId);
return (updateUser != null) ? updateUser.getOrgId() : null;
}
Repository class
@Repository
public interface MappingRepository extends JpaRepository<Mapping,String> {
Mapping findByIasId(String iasId);
}
Model Class
@Data
@Entity
@Table(name = "tablename")
public class Mapping {
@Id
private int id;
private String iasId;
private String orgId;
private String ogId;
}