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.  [ 1 post ] 
Author Message
 Post subject: Query with a join in a list or set mapping?
PostPosted: Thu Aug 30, 2007 3:37 am 
Beginner
Beginner

Joined: Sun Apr 09, 2006 9:07 pm
Posts: 24
Hibernate version: 1.2.0 GA

Name and version of the database you are using: MS SQL 2000

I have three joined tables, say User, Event and EventThing. I'd like to run a query that joins these tables, eg.

SELECT et.thingId
FROM EventThing et
INNER JOIN Event e
ON et.eventId = e.id
INNER JOIN User u
ON e.userId = u.id
WHERE e.type = 1 and u = 12345

Is it possible to write this query inside a mapping document for the User class somehow and have the list of IDs (et.thingId) stored by NHibernate in an IList or IDictionary in that object whenever it's loaded? I know there's a "where" attribute, but it doesn't seem like I can put a join in there. I also know I can manually run an HQL query, but it would be much nicer to have this done automatically. Ie. I'd like to be able to access the "User.ThingIDs" property and have NHibernate run the query above.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.