Tuesday, 15 June 2010

java - Implementing multiple JOINS in HQL -


I'm trying to implement an HQL query. I am able to implement it in SQL - which I am a bit familiar with, whatever hanging I am, are the inner jones

Classes are implemented like this ...

  class item class component item increases personal items parentItem; The item in the class assembly extends to <0 > 

, that is what I have for HQL ...

  SELECT item.blah, comp .blah, the assembly does this work - except that I need to take an extra left instead of taking the left to the last three rows. I have a mutually exclusive condition I have tried to apply it in many ways - but I Running into mapping problems.  
  & lt; Hibernate-Mapping & gt; & Lt; Class lazy = "false" name = "com.kcp.common.domain.inventory.item" table = "W_INV_INV_ITEM" where = "deleted = 0" & gt; & Lt; Connected-subclass lazy = "false" name = "com.kcp.common.domain.inventory.Component" table = "W_INV_INV_COMPONENT" & gt; & Lt; Key & gt; & Lt; Column name = "id" & gt; & Lt; Comment & gt; W_INV_INV_ITEM to primary and foreign keys & Lt; / Comment & gt; & Lt; / Column & gt; & Lt; / Key & gt; & Lt; Several-to-one cascade = "all" class = "com.kcp.common.domain.inventory.Item" name = "parentItem" external-included = "true" & gt; & Lt; Column name = "PARENT_ITEM_ID" & gt; & Lt; Comment & gt; The foreign key recognizing the component that this component is gathered. & Lt; / Comment & gt; & Lt; / Column & gt; & Lt; / Many-to-one & gt; & Lt; Joined in / subclass & gt; & Lt; Included- sub-class lazy = "false" name = "com.kcp.common.domain.inventory.Assembly" table = "W_INV_INV_MAJOR_ASSEMBLY" & gt; & Lt; Key & gt; & Lt; Column name = "id" & gt; & Lt; Comment & gt; W_INV_INV_ITEM to primary and foreign keys & Lt; / Comment & gt; & Lt; / Column & gt; & Lt; / Key & gt; & Lt; / Square & gt; & Lt; / Hibernate-mapping & gt;  

In addition to this - I got to work on such a SQL ...

If you include the position of a left join in the WHERE clause, it will act as the INNER jOIN.

If before Alternatively, the item.parentItem should be optional, so you should include that which is in a lower part .

It HQL query a terrible will generate SQL queries and you should customize it anyway.

Try something like this:

  Select i.blah, when excluding component c.blah C c.parentItem I empty I.parentItem p WHERE p spaces Or P.class = 'assembly' class item class component item extends personal item parentItem; Increases class assembly items  

No comments:

Post a Comment