Tho*_*att 3 nhibernate hql fluent-nhibernate ora-00933 hql-delete
为什么以下HQL查询失败?
string hql = @"delete MyLog log
where
log.UtcTimestamp < :threshold and
log.Configuration.Application = :application";
session.CreateQuery(hql)
.SetDateTime("threshold", threshold)
.SetEnum("application", this.application)
.ExecuteUpdate();
Run Code Online (Sandbox Code Playgroud)
在select中使用相同形式的查询:
string hql = @"from MyLog log
where
log.UtcTimestamp < :threshold and
log.Configuration.Application = :application";
IList<MyLog> log = session.CreateQuery(hql)
.SetDateTime("threshold", threshold)
.SetEnum("application", this.application)
.List<MyLog>();
Run Code Online (Sandbox Code Playgroud)
MyLog的映射包含:
References(x => x.Configuration)
.Columns("CONFIGURATION_ID")
.ReadOnly();
Run Code Online (Sandbox Code Playgroud)
Configuration的映射包含:
Map(x => x.Application, "APPLICATION_ID");
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
从MYLOG中删除,CONFIGURATION countercon1_,其中UTC_TIMESTAMP <:p0和APPLICATION_ID =:p1; :p0 = 04/10/2010 17:15:52,:p1 = 7
NHibernate.Exceptions.GenericADOException:无法执行更新查询[SQL:
从MYLOG,CONFIGURATION中删除countercon1_,其中UTC_TIMESTAMP <?和APPLICATION_ID =?
] ---> Oracle.DataAccess.Client.OracleException:ORA-00933:SQL命令未正确结束
试试这个:
delete MyLog log
where log.id in
(select l.id
from MyLog l
where l.UtcTimestamp < :threshold and
and.Configuration.Application = :application)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7918 次 |
| 最近记录: |