-->
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: sql join...Can someone show an example..
PostPosted: Wed Sep 17, 2003 2:09 pm 
Beginner
Beginner

Joined: Wed Sep 17, 2003 10:25 am
Posts: 36
Still trying to get a handle on the joining. I would like to eventually use left and right joins but for now trying this query below and comparing it with one where I use paths day.meetingDays.meeting.schedule.scheduleId=1.

This is my join query: (The examples in the documentation do not cover this case)

Query q = session.createQuery("select day " +
" from Day as day inner join" +
" MeetingDays.day as md inner join" +
" Meeting.meetingId as m join" +
" Schedule.scheduleId as schedule" +
" where schedule.scheduleId=1 ");

I keep getting the following error:

net.sf.hibernate.QueryException: undefined alias: Meeting

Relationships are as follows:

Day to MeetingDays is a one to many from Day to MeetingDays with inverse set to true.
Meeting to MeetingDays is a one-to-many with inverse=true.
Schdedule to Meeting is a one-to-many with inverse=true.

when I add the package names to the classes my.package.name.MeetingDays, I get an undefined alias issue as well.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 17, 2003 3:16 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I don't think it makes sense to join a mapped object with an attribute !
As I don't think it makes sense to map a table with a column in SQL.

Never played whith join, so take it 'as is' but your query would probably much look like

Code:
select day from Day as day inner join day.meetingdays as md inner join meetingdays.meeting as meeting inner join meeting.schedule as schedule where schedule.scheduleId=1


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.