Xzajo's Weblog

All | Java | nbxdoclet | NetBeans | Personal | Project Extensions | Sun | Testing
« Emma Code Coverage... | Main | Select J2SE library... »
20060325 Saturday March 25, 2006

Hibernate Query Wizard for Netbeans 5.0

Hibernate is equipped with an extremely powerful query language that (quite intentionally) looks very much like SQL. But don't be fooled by the syntax; HQL is fully object-oriented, understanding notions like inheritance, polymorphism and association.

HQL Wizard for NetBeans 5.0 helps to create selects in HQL. The wizard is part of hibernate plugin based on xdoclet. The project pages are on nbxdoclet website. The HQL wizard can be open be using code completion of hibernate bean's (POJO) facade class.

The wizard is shown bellow:

Detailed steps how to create the query in the example:

  1. To create first join select USER -> N-1: Address address property in entities view and click to Add button. The address is added to Entities list.
  2. To add first Left Parameter select address -> town item and click to Add button.
  3. Type ? to First right parameter.
  4. To create second join select User -? N-1: Car car item and click to Add button.
  5. Add two user -> age rows. It is similiar like adding car -> type row.
  6. To add first parentheses select car.typ="fiat" and user.age > 20 rows and click to Set Or button.
  7. To add second parentheses select user.age < 50 and user.age > 20 rows and click to Set And button.
  8. Change generated method name to getFiatForTown.

After click to Ok button code, shown bellow, is generated to facade class:

 public java.util.List getFiatForTown(java.lang.String addressTown) {
        Session session = store.HibernateUtil.currentSession();
        org.hibernate.Query query = session.createQuery(
                " select user " +
                " from  " +
                " User as user " +
                " join user.address as address " +
                " join user.car as car " +
                "  where  " +
                " address.town = ? " +
                "  and  (car.type = \"fiat\" " +
                "  OR  (user.age < 50 " +
                "  AND user.age > 20) " +
                " ) ");
        query.setParameter(0,addressTown);
        
        return query.list();
    }

The wizard read the information about entities (POJO) from xdoclet tags. It it not so difficult to implement reading of EJB30 annotations. I'm not sure if someone wants to use it with annotations. Is this wizard handy? Please give me feedback and report bugs to nbxdoclet's bug tracing system.

Posted by xzajo ( Mar 25 2006, 09:25:57 PM CET ) Permalink Comments [30]

Comments:

Hi, how did you add the HQL wizard to code completion? I'm really curious.

Posted by Geertjan on March 26, 2006 at 04:15 PM CEST #

I wrote (copy + past from a existing provider :getter + setter in java.. ) code completion provider:
org.netbeans.modules.xdoclet.livetemplates.CompletionProvider
The provider is able to proccess this descriptor:

<livetemplates group="hibernate">
    <livetemplate name ="Hibernate Facade" 
                  descriptorRef="sf-netbeans-nbxdoclet-hibernate-FacadeDescriptor.instance"
                  iconpath="sf/netbeans/nbxdoclet/hibernate/templates/hibernateIcon.gif">
     <classquery>hibernateBean</classquery>
    <!--     <property name="customizer" value="org.netbeans.modules.xdoclet.livetemplates.hibernate.HibernateRelation11Panel"/>    -->
      <bean id="hibernate" classRef="sf-netbeans-nbxdoclet-hibernate-HibernateEnv.instance"/>
      <bean id="bean"      classRef="sf-netbeans-nbxdoclet-hibernate-HibernateBeanInstance.instance"/>
       <velocitytemplate name="HibernateFacade.vm" newFile="true"  >
               <useBean refid="hibernate" name="hibEnv"/> 
               <useBean refid="bean" name="bean"/> 
               <!-- filter for target --> 
               <!--<object>objectInDescript</object> -->
       </velocitytemplate>  
     </livetemplate>
</livetemplates>

The classquery = "hibernateFacade" is declared in xdoclet's definition (hibernate-xdoclet.xml):

    <classquery classfilter = "defaultClass" name="hibernateFacade" group="hibernate">
        <tagquery name="netbeans.hibernate.facade" mincount="1" maxcount="1" />
    </classquery>
 

Posted by xzajo on March 27, 2006 at 09:59 AM CEST #

How can I make the HQL Wizard comes up when I'm using Netbeans? I already have Hibernate installed. I appreciate.

Posted by David on April 11, 2006 at 04:05 PM CEST #

The HQL wizard is presented in Facade class. Look at flash demo.

Posted by xzajo on April 11, 2006 at 04:16 PM CEST #

Do these steps:

  1. Create Hibernate bean from template
  2. Open code completion window in the hibernate bean and select "Hibernate Facade". The hibernate facede class for the bean is generated.
  3. Open the generated facade java source and show code completion it the class. The HSQL generator will be visible.
Do you have any other problem?

Posted by xzajo on April 11, 2006 at 04:26 PM CEST #

The "hibernate facade" option and all other hibernate options doesn't appear in my code completion window? How do i do?

Posted by kamal on May 04, 2006 at 06:14 PM CEST #

In the last build is bug caused by adding templates for EJB3 and and annotations. All will be working fine in the next version. There are modules with hotfix. But you need to run it with fresh user dir and netbeans installation because I didn't increates specs versions for modules. It can be downloaded here

Posted by xzajo on May 04, 2006 at 06:32 PM CEST #

Sorry about this question, but, how do i put the hibernet plugin in the Navigator-User Window, because i want to create the database but i can't do it without that (According to the flash manual). Please can you help me??

Posted by Jack on May 12, 2006 at 04:28 PM CEST #

There was a bug in code completion. Please update to new version.

Posted by xzajo on May 12, 2006 at 05:10 PM CEST #

What's happening. I've update to the las plugin but every time i try to create an hibernate bean, a warning appears saying that my java file cannot be shared and cannot be accessed. I'm making a mistake or something else?? Please i need help for this one

Posted by Heero on May 13, 2006 at 01:08 AM CEST #

I installed Hibernate 3.1.3 on NetBeans 5.0. The problem is that the code completion does not appear when clicking the right-button on a hibernate Bean. Do you have any idea about this problem?? I'd appreciate some help from anybody. Thanks !!!

Posted by Javi on July 12, 2006 at 06:27 AM CEST #

Have you used Hibernate with struts? I have tried it but a error appears with the library junit and struts. Could exists any conflict with the netbeans struts and the nbxdoclet struts?

Posted by Bea on July 24, 2006 at 10:55 PM CEST #

test

Posted by 12.10.219.45 on September 11, 2006 at 04:49 PM CEST #

Hi, I have already installed Hybernate3.2 from nbxdoclet.But it does not shows me the HSQLGenerator template in the CodeCompletion menu after clicking ctrl + space.As shown in flash demo.It shows all other things Except the HSQLGenerate Template. I would Reaaly appreciate u if u can tell me the steps to add that template to my code completion menu. Thanks.

Posted by Amit on November 08, 2006 at 02:04 PM CET #

[url=http://www.powerleveling-wow.com/]wow power leveling[/url] [url=http://www.powerleveling-wow.com/siteMap.asp]wow power leveling[/url] [url=http://www.powerleveling-wow.com/]wow powerleveling[/url] [url=http://www.powerleveling-wow.com/siteMap.asp]wow powerleveling[/url] [url=http://www.wow-powerleveling-wow.com/]wow gold[/url] [url=http://www.wow-powerleveling-wow.com/gold.asp]wow gold[/url] [url=http://www.wow-powerleveling-wow.com/]powerleveling[/url] [url=http://www.wow-powerleveling-wow.com/wow-powerleveling.asp]powerleveling[/url] [url=http://www.wow-powerleveling-wow.com/]wow powerleveling[/url] [url=http://www.wow-powerleveling-wow.com/wow-powerleveling.asp]wow powerleveling[/url] [url=http://www.wow-powerleveling-wow.com/]wow power leveling[/url] [url=http://www.wow-powerleveling-wow.com/wow-powerleveling.asp]wow power leveling[/url] [url=http://www.wow-powerleveling-wow.com/]power leveling[/url] [url=http://www.wow-powerleveling-wow.com/wow-powerleveling.asp]power leveling[/url] [url=http://www.wow-powerleveling-wow.com/]wow power level[/url] [url=http://www.wow-powerleveling-wow.com/wow-powerleveling.asp]wow power level[/url] [url=http://www.wow-powerleveling-wow.com/]Ddo plat[/url] [url=http://www.wow-powerleveling-wow.com/FinalFantasy.asp?id=58]Ddo plat[/url] [url=http://www.wow-powerleveling-wow.com/]FFXI Gil[/url] [url=http://www.wow-powerleveling-wow.com/FinalFantasy.asp?id=61]FFXI Gil[/url] [url=http://www.wow-powerleveling-wow.com/]GW Gold[/url] [url=http://www.wow-powerleveling-wow.com/FinalFantasy.asp?id=66]GW Gold[/url] [url=http://www.wow-powerleveling-wow.com/]GW Power Leveling[/url] [url=http://www.wow-powerleveling-wow.com/FinalFantasy.asp?id=66]GW Power Leveling[/url] [url=http://www.wow-powerleveling-wow.com/]RS Gold[/url] [url=http://www.wow-powerleveling-wow.com/jinbi.asp?id=1215]RS Gold[/url] [url=http://www.wow-powerleveling-wow.com/]RS Power Leveling[/url] [url=http://www.wow-powerleveling-wow.com/jinbi.asp?id=1215]RS Power Leveling[/url] [url=http://www.wow-powerleveling-wow.com/]Lotro Gold[/url] [url=http://www.wow-powerleveling-wow.com/the-lord-of-the-rings-gold.asp?servertype=us]Lotro Gold[/url] [url=http://www.wow-powerleveling-wow.com/]Lotro Power leveling[/url] [url=http://www.wow-powerleveling-wow.com/the-lord-of-the-rings-gold.asp?servertype=us]Lotro Power leveling[/url] [url=http://blog.tyfo.com/?U=mingxingp]窃听器[/url] [url=http://blog.tyfo.com/?U=fu3lh]福彩3D[/url] [url=http://blog.tyfo.com/?U=banjiagg]搬家公司[/url] [url=http://blog.tyfo.com/?U=liuhep]香港六合彩[/url] [url=http://hi.baidu.com/mingxini/blog]香港六合彩[/url] [url=http://hi.baidu.com/piaolingyue/blog]搬家公司[/url] [url=http://hi.baidu.com/limingi/blog]搬家公司[/url] [url=http://blog.tyfo.com/?U=qietingl1]窃听器[/url]

Posted by 水无痕 on July 21, 2007 at 05:08 AM CEST #

wow power leveling wow power leveling wow powerleveling wow powerleveling

Posted by 水无痕 on July 21, 2007 at 05:11 AM CEST #

<a href="http://www.feelingame.com/">wow power leveling</a>
<a href="http://www.feelingame.com">wow powerleveling</a>
<a href="http://www.cheap-wow-power-leveling.com">cheap wow power leveling</a>
<a href="http://www.cheap-wow-power-leveling.com/">wow power leveling</a>
<a href="http://www.cheap-wow-power-leveling.com/">wow powerleveling</a>
<a href="http://www.cheap-wow-power-leveling.com/">wow power lvl</a>

Posted by 22222 on August 22, 2007 at 09:19 AM CEST #

<a href="http://www.800millions.com">runescape money</a> njmbnmmb

Posted by svss on November 16, 2007 at 08:46 AM CET #

<a href=http://www.800millions.com>runescape money</a>

Posted by svssgfhfgh on November 16, 2007 at 08:46 AM CET #

[url="http://www.zlyg.cn"]棕榈树[/url]

Posted by svssgfhfghsv on November 16, 2007 at 08:47 AM CET #

压力开关 压力变送器 压力传感器 流量开关 流量计 液位计 液位开关 温湿度记录仪 风速仪 差压开关 可燃气体检测仪 过滤器 强磁水处理器 自清洗过滤器 自动反冲洗过滤器 保鲜棕榈树

Posted by svssgfhfghsv on November 16, 2007 at 08:48 AM CET #

The best of luck! Best wishes! Best regards!
http://www.bjseek.com.cn
http://www.bjxlzx.cn
http://www.sense.com.cn
http://jglsx.blog.sohu.com/
http://blog.china.alibaba.com/blog/jglsx.html
http://jglsx.blog.hexun.com/
http://tw.netsh.com/eden/blog/ctl_eden_blog.php?iBlogID=2610970
http://tw.netsh.com/eden/blog/ctl_eden_blog.php?iBlogID=2632783
http://blog.soufun.com/blog_12178456.html
http://blog.china-pub.com/blog.asp?name=jlb148140960
http://www.phpchina.com/38743
http://hexun.com/jglsx/default.html
http://www.xiongcaocao.com/?sid=116
http://jlb999.blog.163.com/
http://jjllbb.eomoo.com/user18/jlb148140960/index.shtml
http://hexun.com/xicao1/default.html
http://hexun.com/xicao3/default.html
http://hexun.com/xicao6/default.html
http://hexun.com/xicao9/default.html
http://hexun.com/xicao2/default.html
http://hexun.com/xicao7/default.html
http://hexun.com/xicao4/default.html
http://hexun.com/xicao5/default.html
http://hexun.com/xicao8/default.html
http://hexun.com/zwwsl/default.html
http://xicao6.blog.hexun.com/
http://xicao7.blog.hexun.com/
http://xicao8.blog.hexun.com/
http://xicao9.blog.hexun.com/
http://zwwsl.blog.hexun.com/
http://xicao1.blog.hexun.com/
http://xicao2.blog.hexun.com/
http://xicao3.blog.hexun.com/
http://xicao4.blog.hexun.com
http://xicao5.blog.hexun.com
http://tzgoogle.blog.hexun.com
http://hexun.com/tzgoogle/default.html
http://blog.ccidnet.com/blog-htm-uid-71265.html
http://hexun.com/baom/default.html
http://baom.blog.hexun.com
http://www.0576w.cn/
http://www.0576w.cn/catalog.asp?cate=1
http://www.0576w.cn/catalog.asp?cate=2
http://www.0576w.cn/catalog.asp?cate=3
http://www.0576w.cn/catalog.asp?cate=5
http://www.0576w.cn/catalog.asp?cate=6
http://www.0576w.cn/post/google.html

Posted by 数据恢复 on February 14, 2008 at 01:56 AM CET #

http://www.wowgolds.co.uk wow gold http://www.wowgolds.co.uk cheap wow gold http://www.wowgolds.co.uk buy wow gold http://www.wowgolds.co.uk world of warcraft gold http://www.wowgolds.co.uk wow http://www.wowgolds.co.uk world of warcraft http://www.wowgolds.co.uk/wow-gold.html wow gold http://www.wowgolds.co.uk/warrior.html WoW Warrior http://www.wowgolds.co.uk/hunter.html WoW Hunter http://www.wowgolds.co.uk/rogue.html WoW Rogue http://www.wowgolds.co.uk/paladin.html WoW Paladin http://www.wowgolds.co.uk/shaman.html WoW Shaman http://www.wowgolds.co.uk/priest.html WoW Priest http://www.wowgolds.co.uk/mage.html WoW Mage http://www.wowgolds.co.uk/druid.html WoW Druid http://www.wowgolds.co.uk/warlock.html WoW Warlock http://www.powerleveling2.cn power leveling http://www.powerleveling2.cn powerleveling http://www.wowpowerleveling2.cn wow power leveling http://www.wowpowerleveling2.cn wow powerleveling http://www.wowpro.cn wow guides http://www.wowmmo.cn wow tips http://ggtop.nbatop.com google排名 http://ggtop.nbatop.com google左侧排名 http://ggtop.nbatop.com google排名服务 http://www.baidupaiming.net 百度推广 http://www.baidupaiming.net 百度排名 http://www.fzqsnet.cn 网站推广 http://www.thebiz8.com 商业吧 http://www.thebiz8.com/jichuang.html 机床 http://www.thebiz8.com/leddeng.html LED灯 http://www.thebiz8.com/dianchi.html 电池 http://www.thebiz8.com/suliao.html 塑料 http://www.thebiz8.com/shexiangji.html 摄像机 http://www.thebiz8.com/yimin.html 移民 http://www.thebiz8.com/jiachun.html 甲醇 http://www.thebiz8.com/ranliao.html 染料 http://www.0591qs.cn 福州热线 http://www.sportblog.org.cn 体育博客 http://www.stockblog.org.cn 股票博客 http://www.gameblog.org.cn 游戏博客 http://www.cheap-wow-gold.org.cn 魔兽博客 http://www.excamtest.cn 考试博客 http://www.carblog.org.cn 汽车博客 http://www.houseblog.org.cn 房产博客 http://www.pcblog.org.cn 电脑博客 http://powerlin518.iblog.com powerlin518 http://www.xcelwebdesign.com logo design http://www.xcelwebdesign.com website design http://www.xcelwebdesign.com web design http://www.shangbiaodesign.cn 商标设计

Posted by power leveling on March 20, 2008 at 04:14 PM CET #

http://www.hrzbq.com

Posted by 深圳搬家公司 on April 06, 2008 at 09:15 AM CEST #

http://www.sz-hrzbj.cn

Posted by 深圳搬家 on April 06, 2008 at 09:24 AM CEST #

深圳搬家公司 <p><a href="http://www.hrzbq.com" rel="nofollow">深圳搬家公司</a></p>

Posted by 深圳搬家 on April 06, 2008 at 09:28 AM CEST #

<a href="http://www.sz-hrzbj.cn" rel="nofollow"><strong>深圳搬家</strong></a>>

Posted by 123 on April 06, 2008 at 09:33 AM CEST #

http://sunnyren.weblog.com
this blog introduces jewelry products and fashion jewelry.

Posted by fashion jewelry on October 31, 2008 at 06:05 AM CET #

Post a Comment:

Comments are closed for this entry.

Calendar

RSS Feeds

Search

Links

Navigation

Referers