This class is not directly related to one table so if it has to be mapped I'm not sure how I would do it. Is it required that the results of a stored procedure call be a class mapped in a hibernate-mapping?
I'm not sure how I would map this object. Like I said its not directly related to a table. What this is doing is calling a stored procedure that does a search across multiple tables and returns result rows that span multiple tables.
So using the properties and the columns you have above in your stored procedure call, you create a class mapping that has those properties mapped to those columns, you do not need a table tag for this mapping.
Joined: Aug 21, 2006
I mapped the class and the stored procedure in the same hibernate mapping as follows
This mapping seems to be just fine. When I try to execute the query, I get a SQLException with Invalid Parameter Binding. The stored procedure on my SQLServer DB is just a select across multiple tables
SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO
ALTER PROCEDURE dbo.getSearchResults @pManagerId INT , @pStartDate smalldatetime , @pEndDate smalldatetime AS BEGIN SET nocount on select distinct manager.ManagerID as managerId, manager.ManagerName as managerName, le.FiscalYearEnd as fiscalYearEnd from Managers manager join legalEntities le on manager.managerId = le.managerId join partnershipLegalEntityMap ple on le.LegalEntityId = ple.LegalEntityId join funds f on ple.fundId = f.fundId join managerMapping mm on manager.managerId = mm.managerId join managerComposite mc on mm.CompositeId = mc.CompositeId JOIN strategyMapping sm ON mc.CompositeID = sm.compositeId join strategy s on sm.StrategyId = s.strategyId WHERE manager.ManagerID = isnull(@pManagerId, manager.ManagerID) SET nocount off END
GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO
Besides the SQLException problem, how do I map the id field if its not really an id on a specific table as in this case?
subject: Stored Procedure - Can use unmapped class for result?