Spring StoredProcedure对象返回对象列表

时间:2013-03-12 10:20:37

标签: mysql spring stored-procedures jdbctemplate

我使用mysql存储过程来检索对象列表。这可能吗 ?

我正在关注此article

问题:

  1. 如何使用结果集检索select语句中的对象列表?
  2. 如何将结果集映射到对象列表?

    CREATE DEFINER = root @ localhost程序generateLCRReport(IN countryCodeParam INT,OUT countryCode INT,OUT dialCode INT,OUT { {1}} VARCHAR(50),OUT custPrefix VARCHAR(50),OUT vendorPrefix FLOAT,OUT custPrice FLOAT,OUT vendorCost FLOAT)     语言SQL     确定性     读取SQL数据     SQL安全定义器     评论'generateLCRReport' 开始 选择c.country_code作为countryCode,c.dial_code作为dialCode, c.customer_prefix为custPrefix,c.vendor_prefix为vendorPrefix, max(cust_rate.rate)作为custPrice,min(ven_rate.rate)作为vendorCost, round(max(cust_rate.rate) - min(ven_rate.rate),3)作为利润 来自cdr c

    内部联接 (从速率r中选择a.id,r.rate,re.country_code,re.dial_code,ap.prefix 内连接区域在r.region_id = re.id上 r.account_prefix_id = ap.id上的内连接account_prefix ap 内部联接帐户a在a.id = ap.account_id上 其中ap.prefix_type = 0 )as cust_rate

    on c.country_code = cust_rate.country_code 和c.dial_code = cust_rate.dial_code 和c.customer_prefix = cust_rate.prefix 和c.customer_id = cust_rate.id

    内部联接 (从速率r中选择a.id,r.rate,re.country_code,re.dial_code,ap.prefix 内连接区域在r.region_id = re.id上 r.account_prefix_id = ap.id上的内连接account_prefix ap 内部联接帐户a在a.id = ap.account_id上 其中ap.prefix_type = 1 )作为ven_rate

    on c.country_code = ven_rate.country_code 和c.dial_code = ven_rate.dial_code 和c.vendor_prefix = ven_rate.prefix 和c.vendor_id = ven_rate.id 其中c.country_code = countryCodeParam group by c.country_code和c.dial_code 按c.country_code asc排序 限制5000;

    END

    公共类LCRReportSP扩展了StoredProcedure {

    profit

    }

  3. 请帮忙。

    感谢。

1 个答案:

答案 0 :(得分:0)

我正在使用RowMapper并声明参数SqlReturnResultSet。

相关问题