使用只读事务春季启动来调用存储过程

时间:2018-08-16 12:12:24

标签: mysql spring-boot jpa spring-data-jpa spring-data

我的程序如下:

@NamedStoredProcedureQueries({
    @NamedStoredProcedureQuery(name = "getFilteredServiceCentersStoredProcedure", procedureName = "getFilteredServiceCentersStoredProcedure",parameters = {
            @StoredProcedureParameter(name = "searchText", mode = ParameterMode.IN, type = String.class),
            @StoredProcedureParameter(name = "sectorId", mode = ParameterMode.IN, type = Long.class),
            @StoredProcedureParameter(name = "lat", mode = ParameterMode.IN, type = Double.class),
            @StoredProcedureParameter(name = "lon", mode = ParameterMode.IN, type = Double.class),
            @StoredProcedureParameter(name = "currentLatitude", mode = ParameterMode.IN, type = Double.class),
            @StoredProcedureParameter(name = "currentLongitude", mode = ParameterMode.IN, type = Double.class),
            @StoredProcedureParameter(name = "radius", mode = ParameterMode.IN, type = Double.class),
            @StoredProcedureParameter(name = "serviceCenterTypes", mode = ParameterMode.IN, type = String.class),
            @StoredProcedureParameter(name = "pageOffset", mode = ParameterMode.IN, type = Long.class),
            @StoredProcedureParameter(name = "pageSize", mode = ParameterMode.IN, type = Integer.class),
            @StoredProcedureParameter(name = "totalCount", mode = ParameterMode.OUT, type = Long.class) }) })

我正在尝试使用:

@Transactional(readOnly = true)

春天不断给我:

Connection is read-only. Queries leading to data modification are not allowed

现在我的存储过程是只读的,我希望从我的只读副本中读取它,因此我必须将连接标记为readOnly。

0 个答案:

没有答案