-->
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.  [ 2 posts ] 
Author Message
 Post subject: RIGHT OUTER JOIN
PostPosted: Fri Feb 09, 2007 5:36 am 
Newbie

Joined: Thu Feb 08, 2007 12:51 pm
Posts: 1
Hi!

I have some problem with JOIN!

my Hibernate version is 3

I have two class:
Code:
package pkg;
public class Father {
          private int id;
          private String name;

     public void setId(int id) {this.id = id;}
     public int getId() { return this.id;}

     public void setName(String name) {this.name = name;}
     public String getName() { return this.name;}
}

package pkg;
public class Child extends Father  {
          private int id;
          private String name_child;

     public void setId(int id) {this.id = id;}
     public int getId() { return this.id;}

     public void setName_child(String name_child) {this.name_child = name_child;}
     public String getName_child() { return this.name_child;}
}


...and two mapping files:
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="pkg.Father" table="Father"
       dynamic-update="true" dynamic-insert="true"
       lazy="true" discriminator-value="null">

      <id name="id" type="int">
         <generator class="native"/>
      </id>

      <property name="name" />

   </class>
</hibernate-mapping>


<?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="pkg.Child" table="Child"  dynamic-update="true" dynamic-insert="true" >

      <id name="id" type="int">
         <generator class="native"/>
      </id>

      <property name="name_child" column="name"  />

      <join table="Father" fetch="join" >
           <key column="id"/>
         <property name="name" />
      </join>

   </class>
</hibernate-mapping>


...and this code:
Quote:
session.beginTransaction();
List childi = session.createQuery("from Child").list();
session.getTransaction().commit();


the query generates from hibernate is like this:
Code:
select child.id, child.name_child, father.id, father.name from child left outer join father on child.id=father.id


but i need RIGHT OUTER JOIN, not LEFT OUTER JOIN!
how can i do?

than you








[/quote][/code]


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 11, 2007 11:29 pm 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Hi adel,

you could do it by bidirectional mapping .using child bag in father .Think in term of object .Not in term of native SQL.Hibernate is design in such a way that it work in term of object.

_________________
Dharmendra Pandey


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.