问一个Hibernate与SQL的问题!在Hibernate里调用sql语句,语句用了SQL的自定义函数

沙漠之骆驼 沙漠之骆驼 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
在数据库mssql2000有自定义函数:

CREATE FUNCTION f_ConcatPartys(@org numeric,@date_from datetime,@date_to datetime)
RETURNS VARCHAR(8000)
AS
BEGIN
declare @sql varchar(8000)
set @sql= ''
select @sql=isnull(@sql+'、','')+t_name from [Table] where org_id = @org_id and date_f >= @date_from and date_t <= @date_to order by id
RETURN @sql
END



HQuery hquery=new HQuery();
String hsql="dbo.f_ConcatPartys("+org_id+",'"+date_from+"','"+date_to+"') from [Table] as a where a.date_f >='"+date_from+"' and a.date_t <= '"+date_to+"' and group by a.org_id";
hquery.setQueryString(hsql);
List _list=this.find(hquery);

报错:
net.sf.hibernate.QueryException: undefined alias: f_ConcatPartys [select dbo.f_ConcatPartys(98336778,'20080101','20080101') from ....

请问在hibernate里怎样调用sql的自定义函数
...全文

相关推荐

评论 14
收藏 已收藏
分享
返回顶部