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: Multiple Result Sets
PostPosted: Wed Mar 04, 2009 12:20 pm 
Newbie

Joined: Tue Mar 03, 2009 6:51 pm
Posts: 1
Location: Tulsa, OK
NHibernate version: 2.0.1.4
Name and version of the database you are using: SQL Server 2005

I have a Product entity that is mapped to a view in SQL Server - it has several properties - int ID, string Name, string Brand, string Category.

I have a stored procedure which searches the view in SQL Server - it is performing some logic such as assigning search relevance, and is not suitable for converting to NHibernate criteria API.

The stored procedure returns three result sets:
    A list of the current page of Product entities,
    A list of distinct Brands in the search results (not just the current page),
    A list of distinct Categories in the search results (not just the current page)

I would rather not call two or three separate procedures since that would duplicate the work the SQL server is doing to generate the search result list.

Is there some way to send NHibernate a data reader, and have it return back a list of entities?

If not, is there same way to have NHibernate call a stored procedure, and process multiple resultsets returned into multiple lists of entities? (with different entity types)

I would appreciate any help anyone could offer here. If I have not provided enough information please let me know and I will give any additional information I can.

Thanks,

Scott


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 06, 2009 10:30 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
My first try would be a SQL query with hibernate (CreateSQLQuery("exec ...")). Look what you get as a result set. Then I would have a look at result set transformers (query.SetResultSetTransformer(...)). There should be an interface for writing your own one.

You can also have a look at multi criteria/query. Maybe there is something you can use:

http://ayende.com/Blog/archive/2007/05/20/NHibernate-Multi-Criteria.aspx.

_________________
--Wolfgang


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.