SpringDataJpa存储过程调用
SpringDataJpa通过Repository怎么调用没有OUT参数的存储过程?
我的存储过程是这么定义的
delimiter $$
create PROCEDURE nearbyMarket(IN latitude DECIMAL(9,6), IN longitude DECIMAL(9,6))
BEGIN
DECLARE marketId INT(20);
SELECT id INTO marketId FROM (SELECT min(pow(latitude - a.latitude, 2) + pow(longitude - a.longitude, 2)) AS distance, a.* FROM account_markets a) AS b;
SELECT * FROM account_markets WHERE id = marketId;
END;
$$
delimiter ;
@Entity
@NamedStoredProcedureQuery(
name = "Markets.nearById",
procedureName = "nearbyMarketId",
resultClasses = [AccountMarketsEntity::class],
parameters = [
StoredProcedureParameter(name = "latitude", mode = ParameterMode.IN, type = BigDecimal::class),
StoredProcedureParameter(name = "longitude", mode = ParameterMode.IN, type = BigDecimal::class)
]
)
@Table(name = "account_markets")
@DynamicInsert
@DynamicUpdate
class AccountMarketsEntity()
# Repository中
@Procedure(name = "Markets.nearBy")
fun retrieveNearbyMarketByLocation(@Param("latitude") latitude: BigDecimal, @Param("longitude") longitude: BigDecimal): AccountMarketsEntity?
执行程序时retrieveNearbyMarketByLocation方法被当作方法查询了,提示AccountMarketsEntity没有retrieveNearbyMarketByLocation这个属性
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论