I have an Entity
@Entity
public class PromoAmtRange implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "low")
private Integer low;
@Column(name = "high")
private Integer high;
@Column(name = "threshold")
private Integer threshold;
//
constructor & getters setters
}
and its Repository
public interface PromoAmtRangeRepository extends JpaRepository<PromoAmtRange,Long> {
@Query("SELECT pa FROM PromoAmtRange pa WHERE :intValue BETWEEN pa.low AND pa.high")
PromoAmtRange findByThreshold(@Param("intValue") Integer intValue);
}
Note : as you can see intValue is not a member variable of entity class.
I want to get data when intValue fall BETWEEN low and high?
for example I have database entry as shown in picture:
if my intValue is 50 I should get first row i.e.
1 | 0 | 100 | 30
How to achieve this?