Ami*_*rad 3 java postgresql hibernate
我在我的Hibernate中使用了以下查询,即createSQLQuery
SELECT to_char(dd, 'Mon YYYY') FROM generate_series('2013-01-01'::date, date_trunc('month', now()), '1 month') as dd
Run Code Online (Sandbox Code Playgroud)
在PostgreSQL中运行时生成输出
但是,当通过如下的createSQLQuery使用它时,它会抛出" org.hibernate.QueryException:并未设置所有已命名的参数:[:date] "
请注意,日期已被用作' 2013-01-01':: date
try{
session = HibernateSessionFactory.getSession();
tx = session.beginTransaction();
Query query = session.createSQLQuery("SELECT to_char(dd, 'Mon YYYY') FROM generate_series('2013-01-01'::date, date_trunc('month', now()), '1 month') as dd");
monthList = new ArrayList<String>();
monthList = query.list();
tx.commit();
}
Run Code Online (Sandbox Code Playgroud)
请建议
| 归档时间: |
|
| 查看次数: |
4689 次 |
| 最近记录: |