如何测试HQL查询? [英] How to test HQL queries?

查看:91
本文介绍了如何测试HQL查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种快速(非常快速)的方式来测试对hibernate查询的更改。我有一个巨大的应用程序,其中包含数千个不同的HQL查询(在XML文件中)和100多个映射类,我不想重新部署整个应用程序来测试对查询的一个小改动。

一个好的安装程序会如何让我从重新部署中解脱出来并启用快速查询检查? Intellij IDEA 8.1.3选择的机制被称为'Facet'。要立即测试HQL查询:


  1. 创建数据源工具 - >数据源,添加数据源,定义驱动程序,用户名和密码开发db

  2. 如果您没有hibernate.cfg,或者您以不同于xml的方式配置会话工厂:创建引用所有XML映射的hibernate.cfg文件(定义一个会话工厂的名称,以方便处理)
  3. 在'Project Structure'中添加Facet到您选择的模块,并将最近定义的数据源分配给新的元素
  4. 切换到Java EE View

  5. 打开Hibernate Facets - 节点
  6. 右键单击Session factory并选择打开HQL控制台 / li>
  7. 在控制台
    中输入HQL查询并完成。

对于这个RTFM问题感到抱歉。


I'm searching for a fast (really fast) way to test changes to hibernate queries. I have a huge application with thousands of different HQL queries (in XML files) and 100+ mapped classes and i dont want to redeploy the whole application to just test one tiny change to a query.

How would a good setup look like to free me from redeployment and enable a fast query check?

解决方案

With Intellij IDEA 8.1.3 the mechnism of choice is called 'Facet'. To instantly test HQL queries:

  1. create a data source Tools -> Data Source, Add Data Source, define driver, username and password of yor development db
  2. in case you dont have already a hibernate.cfg or you configure your session factory in a different way than via xml: create a hibernate.cfg file referencing all XML mapping's (define a name for the session factory, just for easier handling)
  3. in 'Project Structure' add Facet to your module of choice and assign the recently defined data source to the new facet
  4. switch to Java EE View
  5. Open Hibernate Facets - Node
  6. Right click Session factory and choose "Open HQL Console"
  7. enter HQL query in console ...and your're done.

sorry for this RTFM question.

这篇关于如何测试HQL查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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