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这个属性

阅读 704
评论
    0 个回答
    撰写回答

    登录后参与交流、获取后续更新提醒