posted 17 years ago
I mapped the class and the stored procedure in the same hibernate mapping as follows
<hibernate-mapping>
<class
name="manager.ManagerSearchResultsBean"
entity-name="managerSearchResultsBean">
<id name="managerID">
<generator class="assigned" />
</id>
<property name="managerName" />
<property name="yearEnd"/>
</class>
<sql-query name="getSearchResults_SP" callable="true">
<return alias="managerSearchResultsBean" entity-name="managerSearchResultsBean"/>
{? = call dbo.getSearchResults (:managerID, :startDate, :endDate)}
</sql-query>
</hibernate-mapping>
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?