-->
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.  [ 1 post ] 
Author Message
 Post subject: xml and entity (hql&SQL)
PostPosted: Thu Sep 11, 2008 12:05 am 
Newbie

Joined: Fri Aug 29, 2008 3:08 pm
Posts: 3
is this true?
hql use xml to create results that hibernate can use. Simialar to the SQL?
here is what I need in a table
Code:
SELECT i.instr_lname,b.book_num,s.stu_lname,b.book_start_date,b.book_start_time,b.book_end_time FROM instructor AS i,booking AS b,student AS s where i.instr_num=b.instr_num AND b.stu_num=s.stu_num;


here is the mapping classes to the (obj)entity classes.

the booking class is searched based on the join between Instructor and student tables
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
  <class dynamic-insert="false" dynamic-update="false" mutable="true" name="lesson.Booking" optimistic-lock="version" polymorphism="implicit" select-before-update="false" table="Booking">
      <id column="book_num" name="bookNum">
          <generator class="increment"/>
      </id>
      <property column="book_start_date" name="bookStartDate"/>
      <property column="book_start_time" name="bookEndTime"/>
      <property column="book_end_time" name="bookEndTime"/>
      <set cascade="all-delete-orphan" inverse="true" lazy="true" name="trips" table="booking">
          <key column="book_num"/>
          <one-to-many class="lesson.booking"/>
      </set>
     
  </class>
</hibernate-mapping>

this is the instructor xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
  <class dynamic-insert="false" dynamic-update="false" mutable="true" name="lesson.Instructor" optimistic-lock="version" polymorphism="implicit" select-before-update="false" table="instructor">
      <id column="instr_num" name="instrNum">
          <generator class="increment"/>
      </id>
      <id column="instr_lname" name="instrName"/>
  </class>
</hibernate-mapping>



this is the student xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
  <class dynamic-insert="false" dynamic-update="false" mutable="true" name="lesson.Student" optimistic-lock="version" polymorphism="implicit" select-before-update="false" table="student">
      <id column="stu_num" name="stuNum">
          <generator class="increment"/>
      </id>
      <property column="stu_lname" name="stuName"/>
         
  </class>
</hibernate-mapping>


If you create a object variable to hold a table element do you have to do the same if you just need a table element to join another table?
ex WHERE i.instr_num=b.instr_num (I need i.instr_num as a key but b.instr_num is just the convention to join.Do I need the same in the xml?


If someone could clear some of this up every little bit of feed back would help.
Thanks
-Steve


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

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.