-->
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: How to search set of tables involving two 1->n relationships
PostPosted: Wed Jan 05, 2011 12:48 pm 
Newbie

Joined: Wed Jan 05, 2011 12:31 pm
Posts: 1
Greetings...

I am trying to use Hibernate's Criteria query API to search against a set of tables with the following relationships:

* A course can be offered in a particular year, managed in the OFFERING table
* A course can have one or more subject code/course number representations, managed in the PROGRAM_OFFERING table
* A course can have one or more course attributes, such as its being designated as a Science course or a Humanities course, managed in the OFFERING_ATTR table

So... I have two 1 -> n relationships here to query against. The primary goal is the following:

* Be able to query by subject code, if one exists
* Be able to query by attribute, if one exists
* Be able to produce a result set, with one record per offering and the list of subject code/course numbers per offering, and the list of course attributes per offering

The challenge is how to do this without resorting to either stored procedures to concatenate these lists (or other Oracle-isms such as user-defined aggregation functions) in the driving query or manually condensing duplicate records after producing the result set which seems inelegant as I would think Hibernate should have some way of handling this use case. Regarding the former, I would prefer to avoid having to write any DB code as so far we have not had to for anything be they views, SQL types, functions, packages etc.; we chose Hibernate specifically for that reason. Regarding the latter, I thought I could do something with the ResultTransformer but it's either not the appropriate thing to use or I'm not doing it right.

I hope I explained this sufficiently; by all means let me know if I need to supply more information.

Gratefully,

dan kefford
technical lead
yale university


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.