为什么以下 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();
在 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>();
MyLog 的映射包含:
References(x => x.Configuration)
.Columns("CONFIGURATION_ID")
.ReadOnly();
配置的映射包含:
Map(x => x.Application, "APPLICATION_ID");
我得到的错误是:
从 MYLOG 中删除,CONFIGURATION countercon1_ where UTC_TIMESTAMP<:p0 and APPLICATION_ID=:p1; :p0 = 04/10/2010 17:15:52, :p1 = 7
NHibernate.Exceptions.GenericADOException:无法执行更新查询 [SQL:
从 MYLOG 中删除 CONFIGURATION countercon1_ where UTC_TIMESTAMP< ? 和 APPLICATION_ID= ?
] ---> Oracle.DataAccess.Client.OracleException: ORA-00933: SQL 命令未正确结束