-->
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: Creating 2D arrays from queries
PostPosted: Mon Jul 24, 2006 10:19 pm 
Newbie

Joined: Wed Jul 19, 2006 5:33 pm
Posts: 1
Is there anyway to create queries which return 2 dimensional arrays

I would like to something similar to this hypothetical situation

Say I have a table containing information about books, ie. author, date of publishing etc.

Is there anyway I can create a query which groups books by author or date.

eg. If I had only 20 books 10 of them being John Steinbeck and the other 10 Thomas Pynchon.

I would like to do a query and group by authors such that I obtain a 2 dimensional array of size 2x10

The first array having steinbeck books and the second pynchon.

Any thought's ideas and could this be done on n-dimensions?

eg. done on author and year so I get n-rows for books for every unique combination of author and year.

Thanks,
dave


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 25, 2006 12:13 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
In JDBC, you can return two result sets. In hibernate, you can't: even if you could, it wouldn't help much, as you still have to issue two selects to do that, and thus you might as well do it using two queries.

The ORM way of doing this would be to map a collection of books in each author, then just select all authors. Not an array, but certainly grouped by author.

If you want only a simple report query, returning the books ordered by author (for easy grouping in java), that's easy. If you need help with that, post again.

_________________
Code tags are your friend. Know them and use them.


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.