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: Basic HQL
PostPosted: Fri Aug 04, 2006 2:51 pm 
Newbie

Joined: Thu Jan 12, 2006 6:02 pm
Posts: 9
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

3.1.1

Mapping documents:

Annotations

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

MySQL 5.0.18

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Basic model:

CLASSROOM

// classroom has many students (unidirectional from classroom)
@ManyToMany(fetch=FetchType.LAZY)
STUDENTS

// each student has a category (unidirectional from student)
@ManyToOne(fetch=FetchType.EAGER)
CATEGORY


I'm trying to use HQL to get the list of categories for a classroom. I tried:

select c.students.category from Classroom c where c.id = :classroomId

but hibernate doesn't like that.

Any thoughts?

Thanks,

Jim


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 05, 2006 2:18 am 
Beginner
Beginner

Joined: Wed Dec 28, 2005 3:14 pm
Posts: 29
I would write
select s.category from Classroom c left join c.Students s where c.id = :classroomId


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.