-->
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: joining a view with a table
PostPosted: Fri May 21, 2010 3:24 am 
Newbie

Joined: Fri May 21, 2010 2:54 am
Posts: 3
hi
I have to join two views and a table where they have a cloumn in common,
i tried as follows but its not working

Csystem, ASystem are views
Sag is a table

Actual SQL to be converted into HQL is

FROM CSYSTEM S1,ASYSTEM A1,SAG SA
WHERE S1.SID=A1.SID(+) AND S1.SID=SA.SID(+)

from Csystem as c1 right join Asystem as a1,
Sag as sa left join c1
where c1.sid = a1.sid and c1.sid=sa.sid

Basic problem here is views doesnt have primary keys to map to other tables

Any solution for joining views by HQL?

error is
------
[org.hibernate.hql.PARSER] - Path expected for join!
[org.hibernate.hql.PARSER] - Invalid path: 'sa.id'
taxException: Path expected for join! [ from com.net


Raj


Top
 Profile  
 
 Post subject: Re: joining a view with a table
PostPosted: Fri May 21, 2010 4:30 am 
Newbie

Joined: Fri May 07, 2010 5:40 pm
Posts: 4
I think you should read about theta-style joins in HQL described in "Java persistance with Hibernate" chapter 14.3.1
Quote:
Theta-style joins
A product lets you retrieve all possible combinations of instances of two or more
classes. This query returns all ordered pairs of Users and Category objects:
from User, Category
Obviously, this isn’t usually useful. There is one case where it’s commonly used:
theta-style joins.
In traditional SQL, a theta-style join is a Cartesian product together with a
join condition in the WHERE clause, which is applied on the product to restrict
the result.
In HQL and JPA QL, the theta-style syntax is useful when your join condition
isn’t a foreign key relationship mapped to a class association. For example,
suppose you store the User’s name in log records, instead of mapping an association
from LogRecord to User. The classes don’t know anything about each other,
because they aren’t associated. You can then find all the Users and their
LogRecords with the following theta-style join:
from User user, LogRecord log where user.username = log.username


Top
 Profile  
 
 Post subject: Re: joining a view with a table
PostPosted: Sun May 23, 2010 4:27 am 
Newbie

Joined: Fri May 21, 2010 2:54 am
Posts: 3
Hi

Thanks for ur early reply,

but in my case i need outer join (left or right) but not cross join
So please let me know how can i do this outer join from a view which doesn't have association with
other view or table.

regards,
Mallik


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.