-->
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.  [ 5 posts ] 
Author Message
 Post subject: Joining on unmapped tables
PostPosted: Mon Mar 05, 2007 4:42 am 
Newbie

Joined: Mon Mar 05, 2007 4:38 am
Posts: 17
I'm pretty new to Hibernate and am building a search function in a table.
To filter my results, I would have to join on one or more tables that are not mapped to Java objects (since I don't need them anyway in my program).

Is there any way I could do this or must I really create objects an map them?
Or also: Is this possible with HQL without using createSQLQuery?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 05, 2007 6:42 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
Yes. Use HQL and try a theta-style join. (T1.ID=T2.FOREIGN_ID)

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 05, 2007 8:16 am 
Newbie

Joined: Sun Mar 04, 2007 5:19 am
Posts: 8
I don't know if i got you right or not but i will assume a situation that might be clse to what you want

Table1 Address
column1 -- > ID (INT)
column2 -- > Street (VarChar)
column3 -- > State_ID (INT)

Table2 State
column1 -- > State_ID (INT)
column1 -- > State_Name (VarChar)

Table2 is the one you don't want
you want your class to look like this

class Address{

private int ID;
private String street;
private string state_name;

}

you can do this by doing a join in the mapping xml file
<class name="Adress" table="Address">
.....
<join table="State">
<key column="State_ID"/>
<property name="state_name" column="State_Name"/>
</join>
.....
</class>
This way you will join the classes without making an objects to them


Top
 Profile  
 
 Post subject: In theta style join can we use left outer join?
PostPosted: Fri Mar 16, 2007 2:34 am 
Newbie

Joined: Fri Jun 17, 2005 2:02 am
Posts: 5
batmat wrote:
Yes. Use HQL and try a theta-style join. (T1.ID=T2.FOREIGN_ID)


Hi,

In theta style join can we use left outer join ? In my tables there are no constraints (primarykey,foreign key). I need to use left outer join with two tables that don't have any constraints. Is there some way to do this?
I am using Hibernate 3.2.


thanks,
Tinu


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 16, 2007 6:25 am 
Beginner
Beginner

Joined: Thu Feb 08, 2007 10:40 am
Posts: 46
This is the same issue that I already asked for help here. I am still looking for solution.


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