-->
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.  [ 4 posts ] 
Author Message
 Post subject: retrieving names
PostPosted: Mon Jun 06, 2005 6:01 pm 
Hello all

I have a question..

Lets say I have two tables Department and Professor

The department table has id(primary key), name
Professor table has id(primarykey), name,address

The Dept_Prof table has deptid and profid.

the corresponding entities are defined in C# and also the mapping is done correctly
class Department
{
int id;
string name;
IDictionary Professors;

}

class Professor
{
int id;
string name;

IDictionary Departments;
}


Now how do I retrive the professors who teach a particular dept.
getProfessorsByDept(int id) is my function.. How do i code this function.
Please suggest

Thanks
Sekhar


Top
  
 
 Post subject:
PostPosted: Mon Jun 06, 2005 6:40 pm 
You could use HQL like this somewhere in your code (probably ProfessorsRepository)

Quote:
"from Professor p where p.Departments = :dept"


Let me know if it helps you (and even if it works) and well work from there.

Good luck!

[/quote]


Top
  
 
 Post subject:
PostPosted: Tue Jun 07, 2005 7:00 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
Pseudo-code:

Code:
IDictionary getProfessorsByDept(int id)
{
    Department dept = session.Load(
        typeof(Department), id );
    return dept.Professors;
}


HTH

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 07, 2005 2:55 pm 
Hello,

I am using createcriteria. I am not allowed to use HQl.

thanks
sekhar


Anonymous wrote:
You could use HQL like this somewhere in your code (probably ProfessorsRepository)

Quote:
"from Professor p where p.Departments = :dept"


Let me know if it helps you (and even if it works) and well work from there.

Good luck!

[/quote]


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