-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Help with HQL Query please !!!!
PostPosted: Thu Nov 09, 2006 7:25 am 
Beginner
Beginner

Joined: Fri Oct 06, 2006 7:11 am
Posts: 32
Hi,

I'm looking for some help on how to write a HQL query on my database. I have the SQL needed to get my results but don't know how I should write this in HQL.

I don't think I need to supply the hbm.xml files but if you think it may be necessary then I will do that.

Any Help would be greatly appreciated.

I have the following tables


TABLE DPCS_STATEMENT_TITLE
(
STATEMENT_TITLE_ID NUMBER(19)
STATEMENT_TITLE VARCHAR2(255)
LANGUAGE_ID NUMBER(19)
VET_CERT NUMBER(1)
SELECTABLE VARCHAR2(255)
)

TABLE DPCS_STATEMENT
(
STATEMENT_ID NUMBER(19)
STATEMENT VARCHAR2(255)
STATEMENT_CODE VARCHAR2(255)
LANGUAGE_ID NUMBER(19)
)

And the table that links them together is:

TABLE DPCS_STATEMEMT_TITLE_LINKS
(
STATEMENT_TITLE_ID NUMBER(19)
STATEMENT_ID NUMBER(19)
)

I want to run this SQL as HQL

select t1.STATEMENT_ID from dpcs_statement t1, DPCS_STATEMEMT_TITLE_LINKS t2
where t2.STATEMENT_ID = t1.STATEMENT_ID
and t2.statement_title_id = ? and t1.LANGUAGE_ID = ?

Can anyone help ?

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 09, 2006 7:27 am 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
Since HQL is object oriented, you need to post your mappings please

_________________
Please don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 09, 2006 7:34 am 
Beginner
Beginner

Joined: Fri Oct 06, 2006 7:11 am
Posts: 32
Hi,

Mapping files are below

thanks

StatementTitle.hbm.xml
=================================
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    <class name="ie.gov.agriculture.dpcs.cert.StatementTitle" lazy="false" table="DPCS_STATEMENT_TITLE">
       <id name="statementTitleId" column="STATEMENT_TITLE_ID" unsaved-value="0" type="long">
           <generator class="native"/>
       </id>
        <property name="title" column="STATEMENT_TITLE" type="string"/>
        <property name="selectable" column="SELECTABLE" type="string"/>

      <many-to-one name="certLanguage"
                column="LANGUAGE_ID"/>
               
         <set name="statements" table="DPCS_STATEMEMT_TITLE_LINKS" cascade="all">
          <key column="STATEMENT_TITLE_ID"/>
          <many-to-many column="STATEMENT_ID"
                        class="ie.gov.agriculture.dpcs.cert.Statement"/>
      </set>

    </class>
   <query name="statement.title.list">
      from StatementTitle StatementTitle
   </query>
</hibernate-mapping>




Statement.hbm.xml
==================================
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    <class name="ie.gov.agriculture.dpcs.cert.Statement" lazy="false" table="DPCS_STATEMENT">
       <id name="statementId" column="STATEMENT_ID" unsaved-value="0" type="long">
           <generator class="native"/>
       </id>
        <property name="statement" column="STATEMENT" type="string"/>
        <property name="statementCode" column="STATEMENT_CODE" type="string"/>
            
      <many-to-one name="certLanguage"
               column="LANGUAGE_ID"/>
    </class>
   <query name="statement.list">
      from Statement Statement
   </query>
   
</hibernate-mapping>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.