问题标签 [criteria]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c# - 如何限制 NHibernate 的 GetByCriteria 拉回的结果集?
我有一个 NHibernate Dao..let 称它为 MyClassDao,因为需要一个更好的名字。
我正在编写以下代码。
我在单元测试中使用它来从数据库中提取值。但是,运行测试需要 30 多秒,这在我看来太长了……所以我想做的是将被拉回的结果集限制为……比如说大约 5 个值。
在 sql 我会做类似下面的事情来实现这样的事情
有没有办法...不使用 NHibernate 查询语言来限制结果集的大小?
c# - How do IN () statements work in NHibernate? (Using Criteria)
I'm trying to create the equivalent of the below using NHibernate. I've done all the mappings using fluent and I can do the basic queries just fine but I have no idea how to do this.
Now I need to do this:
Baring in mind the Product table has been simplified a great deal for the post and that I would prefer to use an IN statement to keep the rest of the query simpler. I would ideally like to create the query using Criteria becuase I will be using Criteria to page the results.
Thanks in advance
hibernate - 休眠条件 - 在 n:m 关系中查询表
我正在尝试为以下场景构建一个带有休眠条件的查询:
- 两个实体:指标和报告(每个都有自己的表格、类等)
- 一个指标可用于零到多个报告
- 报告使用零到多个指标
- 因此,我有一个交集表来存储关系
- 关系在两个类及其休眠映射中定义
- 在 UI 中,用户可以选择一个或多个报告(除其他外),我想在数据库中查询这些报告中使用的指标
我尝试了以下方法:
但我得到的只是一个奇怪的 SQL 语句
然后是 JDBC 异常(缺少参数)
有任何想法吗?谢谢。
注意:我已经研究了Querying ManyToManyrelationship with Hibernate Criteria,但接受的解决方案是构建自定义 sql-string ...
nhibernate - NHibernate 的标准问题
我正在尝试使用 NHibernate 进行数据访问,并且我有 2 个如下所示的简单实体:
我的问题......如果我想在其 Roles 集合中找到包含 ID 为 1 的 Role 的任何用户,我该如何构造一个 Criteria?
nhibernate - 如何在 Expression.Or 中设置 2 个以上的表达式
我想创建一个超过 3-4 Expression.Or 的查询?但是 Expression.Or 只是让我在其中添加两个表达式。
上面的代码生成“Name like %this% or LastName like %this% AND Email1 like %this% and Email2 like %this.
提前致谢。
nhibernate - 在 HQL 或标准中获取 DATEPART?
如何使用 HQL 或 Criteria 获得 DATEPART 时间?我已经用谷歌搜索了它并获得了一些提示,但还不够。如果有人以前经历过,请告诉我们。
提前致谢
mysql - Symfony Propel criteria
Is there any possible way to convert the MySQL object into criteria object? I tried this query:
I tried a lot for converting this query into a Criteria
, But nothing happened. I want this criteria object for passing this into Pager class for completing the pagination.
$pager->setCriteria($c);
.
hibernate - Hibernate Criteria API - HAVING 子句变通方法
我使用 Hibernate Criteria API 编写了一个查询来获取特定值的总和,现在我需要能够将结果限制为总和大于或等于特定值的行。
通常我会在我的 SQL 中使用 HAVING 子句来执行此操作,但 Criteria API 目前似乎不支持它。
在原始 SQL 中,这是我需要它做的事情:
我想到的一种解决方法是在 FROM 子句中使用一个子查询来获取这个总和值,并使用一个外部查询来使用 WHERE 子句来限制它。
因此,在原始 SQL 中,它看起来像:
谁能指出我如何使用 Criteria API 编写此代码的正确方向,或者我可以用来解决 HAVING 问题的任何其他建议/解决方法?
这是我为上述示例提供的 Criteria API 代码
谢谢!
.net - NHibernate:无法成功设置延迟加载
我有一个表 Parent 和一个表 Child。Child 包含 Parent 表的外键,创建一对多关系。这是我用 fluent NHibernate 定义的映射的一部分:
如您所见,我已经在关系上设置了 LazyLoad。另请注意,在我的模型类中,所有属性都设置为虚拟。
现在进行简单查询:
并且生成的SQL:
如您所见,它在 Parent 表上进行连接并选择其字段(id 和 description)。但是,既然我要求延迟加载,为什么它会这样做呢?
现在,如果我将查询更改为:
生成了 2 个 sql 查询:
这对我有好处:不加入,不查询父表。但我也得到了第二个:
再次查询 Parent 表。
这 2 个查询是在行期间生成的:
我完全不知道这里发生了什么。有人可以帮忙吗?
nhibernate - CreateCriteria 和 MONTH
是否可以在 CreateCriteria 语句中使用 MONTH?
NHibernate 是否支持 YEAR 和/或 MONTH?
我有一个 sql 语句,例如 select obs2.Lopnr from Obs obs2 where MONTH(obs2.Datum)=11)
最好的问候
垫子