跨Grails域类进行复杂搜索 [英] Complex search across grails domain classes

查看:137
本文介绍了跨Grails域类进行复杂搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够对grails对象进行复杂的搜索。这是目前使用我网站上的存储过程实现的,这些存储过程构建了一个SQL查询并解析了所有这些结果。

I want to be able to do complex searches on grails objects. This is presently implemented using stored procedures on my site that build up a SQL query and parses all of those results.

类似可搜索插件的东西是否允许我简化这个任务?我的猜测不是,因为它主要是在做基于文本的搜索。存储过程非常复杂,难以改变。我们的用户是员工,这些查询必须与大量的工作经验,他们的工作对象,他们拥有的技能等有关。员工域对象应该包含一些包含技能的角色列表。这个角色将有一个开始和结束日期等。

Will something like the searchable plugin allow me to simplify this task? My guess is not, since it mostly is doing text based searching. The stored procedures are quite complex, and hard to change. Our users are employees, and the queries have to do with amounts of job experience and who they were working for, what skills they have, etc. The Employee domain object would have things like a list of roles that contain skills. The role would have a start and end date, etc.

示例查询列表:

A list of example queries:

All users with 5 years of experience in C++
All users who have worked for Stackoverflow, in California
All users who have at least 5 years of C++ experience, at least 2 years of Java experience, have worked for StackOverflow, and are available to work now.


推荐答案

我从未尝试过可搜索插件,因此可能卖空它。您最好的选择可能是HQL查询或Hibernate条件生成器。我喜欢HQL来处理复杂的查询,因为它与SQL类似。对于比较使用Grails中这些技术的博客文章,请参阅
http://blog.xebia.com/2008/06/04/querying-associations-in-grails-with-hql-criteria-and-hibernatecriteriabuilder/
对于HQL参考,请参阅
http://docs.jboss.org/hibernate/core/3.3/reference/en/html/queryhql.html
对于Hibernate标准,请参阅
http://docs.jboss.org/hibernate/core/3.3/reference/en/html /querycriteria.html

I've never tried the searchable plugin so may be selling it short. Your best bet is probably HQL queries or Hibernate criteria builder. I like HQL for complex queries since it's similar to SQL. For a blog post comparing the use of these technologies from Grails see http://blog.xebia.com/2008/06/04/querying-associations-in-grails-with-hql-criteria-and-hibernatecriteriabuilder/ For the HQL reference see http://docs.jboss.org/hibernate/core/3.3/reference/en/html/queryhql.html For Hibernate criteria see http://docs.jboss.org/hibernate/core/3.3/reference/en/html/querycriteria.html

这篇关于跨Grails域类进行复杂搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆