问题标签 [createcriteria]

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.

0 投票
1 回答
2724 浏览

mysql - Grails Projections 未返回所有属性且未分组

如何得到它,所以我从下面返回所有的预测

结果是这样的:

{"totalCount":2,"data":["company1","company2"]}

我需要它在哪里:

{"totalCount":2,"data":[{"class":"org.example.Company","id":1,"name":"company1"},{"class":"org.example.公司","id":2,"name":"company2"}]}

在公司域中,我有很多关系(一对一、一对多等),我的域如下所示:

包 org.example

导入 java.sql.Timestamp

任何帮助都会很棒:) ????

0 投票
2 回答
997 浏览

hibernate - Hibernate createCriteria list() 返回相同的对象

你能帮我写下面的代码吗?我正在查询 Hibernate,返回的列表中的对象数对应于我的表中的行数。但似乎列表中的每个对象都是相同的。实际上,以下行打印了相同的用户,而表中的用户不同。

这是我的代码

你知道什么会导致这种行为吗?这可能很愚蠢,但我找不到解决方案。谢谢

我的对象代码:

0 投票
3 回答
134 浏览

grails - GRAILS:createCriteria NAND

我在 createCriteria 中的查询中有一堆行,但必须进行一些更改,我需要隐藏列中包含 0 和另一列中字母 A 的行,但如果它们有,我不会隐藏它们0 和另一个字母,我怎样才能在 createCriteria 中做到这一点?我唯一的解决方案是使用 NAND,但我认为它不存在......

有什么建议吗?

0 投票
1 回答
2164 浏览

grails - Grails:使用 Criteria + projections 的结果作为原始表的过滤器

我有下表/模型:

我希望创建一个可以过滤Postid每个Category. 我想要List<Post>形式的结果。

换句话说(我相信)在 SQL 中,查询将如下所示:

如果我理解正确,第一步是使用HibernateCriteriaBuilder

所以我的问题分为两部分:

  1. 我在正确的轨道上吗?

  2. 如何使用结果对象获取List<Post>数组?

    (有点像def latest = Post.FindAllByXXX(result);:)

0 投票
1 回答
392 浏览

nhibernate - 解释 CreateCriteria(typeof(Cat)) 和 CreateCriteria 的区别()

我已经在不同的示例、教程、博客等中看到了这两种格式,但在我的一生中,我无法找到差异的解释。和有什么区别

我什么时候使用一个,什么时候使用另一个?

可以在http://nhibernate.info/doc/nh/en/index.html#quickstart找到使用 session.CreateCriteria(typeof(Cat)) 的教程示例

可以在http://ayende.com/blog/4023/nhibernate-queries-examples找到使用 session.CreateCriteria() 的教程示例(表 Blog 而不是 Cat)

非常感谢!!

0 投票
2 回答
9505 浏览

grails - 带有投影的 CreateCriteria 不会选择所有列

我的问题与 Grails Projections 完全一样 ,没有返回所有属性,也没有分组

我有以下标准

其中 sharedDocuments 定义如下

我所看到的是 sharedDocumentsInstanceList 总是只有投影中提到的最后一个属性。我可以在“withCriteria”中使用相同的查询,但我似乎失去了自动分页的常规优点,因为 withCriteria 不返回分页的 pagedresultlist!

0 投票
1 回答
615 浏览

grails - Can I do a math operation inside a createCriteria

Is it posible to do a math problem inside a createCriteria?

For example:

If in my table I have two columns, if the two together make 100 I don't want to show it in my result of the query

or

if the other column is in other table?

table

I want the second row

or

0 投票
3 回答
12536 浏览

list - grails 列表和 createCriteria()

我有一个 grails web 应用程序的列表功能。此列表将根据某些搜索条件填充表格。我使用 hibernate createCriteria 来尝试实现这一点。

在这种情况下,他们可以通过 2 个不同的关键特征进行搜索。用户名和用户编号。

我唯一的问题是尝试定制函数,以便如果它找到一个空值,它将提示用户其中一个值为空。用户名必须有一个用户编号。如果由于某种原因 userNumber 出现 null 那么它需要提示用户。或者如果没有找到用户名和userNumber的组合,也会提示用户。

这是我的带有搜索条件的列表功能。底部的 println 用于调试,并显示了我想要做什么。

Iv 尝试了 createCriteria 函数的不同组合。像 isNotNull、ilike 等等……我开始认为我不能用 createCritera 做到这一点。这是我用于 createCriteria http://grails.org/doc/2.2.1/ref/Domain%20Classes/createCriteria.html的源代码。

如果有人知道我如何能够使用搜索条件或其他方法来实现我的目标。我将不胜感激一些建议。

谢谢

0 投票
2 回答
2047 浏览

grails - Grails MissingMethodException:WAR 中的 createCriteria,在本地运行

我有一个非常普通的 Grails 应用程序。控制器上的域对象。在本地使用 run-app 或 run-war 时,一切运行良好。当我使用 grails war 创建 WAR 文件并部署到 Tomcat 7.0.25 webapps 目录时,我得到以下信息:

错误 500:内部服务器错误 URI/apps2/mriMetricAdjustment/teamResultAdjustment/list Classgroovy.lang.MissingMethodException MessageNo 方法签名:com.thrivent.mriAdjustment.domain.TeamResultAdjustment.withCriteria() 适用于参数类型:() 值:[]可能的解决方案:withCriteria(groovy.lang.Closure), withCriteria(java.util.Map, groovy.lang.Closure), createCriteria()

withCriteria()是一个域方法,这个错误出现在所有域对象上。我已经尝试了各种清洁、刷新依赖项、战争构建中的各种环境切换(如在 grails prod war 中)。我已经完全摧毁了 Tomcat 上的应用程序并重新部署。没有。我正在使用 Groovy Grails Tool Suite 3.1.0、Grails 2.1.1。任何帮助将不胜感激。

在遇到问题的地方添加堆栈跟踪和代码。每个控制器中的相同位置:

[2013-04-19 16:51:43.931] sysCorpMRIMetricAdjustments ajp-bio-8018-exec-2 错误 rg.codehaus.groovy.grails.web.errors.GrailsExceptionResolver - 处理请求时发生错误 MissingMethodException:[GET] /apps2/ mriMetricAdjustment/teamResultAdjustment/list 没有方法签名:com.thrivent.mriAdjustment.domain.TeamResultAdjustment.withCriteria() 适用于参数类型:() 值:[] 可能的解决方案:withCriteria(groovy.lang.Closure), withCriteria(java .util.Map、groovy.lang.Closure)、createCriteria()。Stacktrace 如下:groovy.lang.MissingMethodException:没有方法签名:com.thrivent.mriAdjustment.domain.TeamResultAdjustment.withCriteria() 适用于参数类型:() 值:[] 可能的解决方案:withCriteria(groovy.lang.Closure) , withCriteria(java.util.Map, groovy.lang.

def results = TeamResultAdjustment.withCriteria { and { like("recordStatusCode", "A") like ("teamID", "%" + params.tsID + "%") } }

使用错误的日志和堆栈跟踪中的片段进行了更新。是否有需要清除的 Tomcat 缓存?

适用于参数类型:() 值:[] 可能的解决方案:createCriteria()。Stacktrace 如下:groovy.lang.MissingMethodException:没有方法签名:>com.thrivent.mriAdjustment.domain.GoalAdjustment.createCriteria() 适用于 >argument 类型:() 值:[] 可能的解决方案:createCriteria() at >com .thrivent.mriAdjustment.controller.GoalAdjustmentController.list(GoalAdjustmentController.groovy:33) 在 >grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilte>r.java:195) 在 grails.plugin.cache.web。 filter.AbstractFilter.doFilter(AbstractFilter.java:63) at >java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java: 908) 在 java.lang.

` 插件 { 运行时 ":hibernate:$grailsVersion" 运行时 ":jquery:1.8.0" 运行时 ":resources:1.1.6"

最后但同样重要的是 - 我重新安装战争时的 catalina 日志:

还有一个更新……这是我安装的插件:

0 投票
1 回答
163 浏览

mongodb - 对于 withCriteria,域对象的 ObjectId 属性集合上是否有“包含”功能?

我有一个订阅域对象,它有一个 ObjectId 列表作为其属性之一,比如“订阅”。我在 Grails 2.1.2 和 MongoDB 上。

我正在寻找这样的东西

有没有办法做到这一点?

注意:我知道同样的问题,但提供的该问题的答案不适用于 ObjectId 列表类型的属性。