Click here to Skip to main content
15,568,965 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi to all.

I have a proyect with c#+nhibernate+fluent+mysql

I don't understand why i have to map the tables in hbm xml file, when this information is in database, but this is other discussions.

My proyect contains this file hbm for store procedure

XML
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="PigCsharp.Entities" assembly="PigCsharp">
  <sql-query name="getparametersbyparameter">
    <query-param name="iParameter" type="string" />
    <return class="mntparameters">
      <return-property column="mntparameters.ident" name="ident" />
      <return-property column="mntparameters.User" name="User" />
      <return-property column="mntparameters.Role" name="Role" />
      <return-property column="mntparameters.Parameter" name="Parameter" />
      <return-property column="mntparameters.value" name="value" />
      <return-property column="mntparameters.Module" name="Module" />
    </return>
    exec getparametersbyparameter   @iParameter = :iParameter
    <!--{ call getparametersbyparameter(:iParameter) }-->
  </sql-query>
</hibernate-mapping>



when I run my code in c#

XML
string param = "getDefaultDatabase";
                var query = session.GetNamedQuery("getparametersbyparameter")
                .SetParameter<string>("iParameter", param).List<mntparameters>();


I have this exception

No se controló NHibernate.Exceptions.GenericADOException
  Message=could not execute query
[ exec getparametersbyparameter   @iParameter = ?p0 ]
  Name:iParameter - Value:getDefaultDatabase
[SQL: exec getparametersbyparameter   @iParameter = ?p0]
  Source=NHibernate
  SqlString=exec getparametersbyparameter   @iParameter = ?p0
  StackTrace:
       en NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) en d:\CSharp\NH\NH\nhibernate\src\NHibernate\Loader\Loader.cs:línea 1703
       en NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters) en d:\CSharp\NH\NH\nhibernate\src\NHibernate\Loader\Loader.cs:línea 1601
       en NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet`1 querySpaces, IType[] resultTypes) en d:\CSharp\NH\NH\nhibernate\src\NHibernate\Loader\Loader.cs:línea 1595
       en NHibernate.Loader.Custom.CustomLoader.List(ISessionImplementor session, QueryParameters queryParameters) en d:\CSharp\NH\NH\nhibernate\src\NHibernate\Loader\Custom\CustomLoader.cs:línea 272
       en NHibernate.Impl.SessionImpl.ListCustomQuery(ICustomQuery customQuery, QueryParameters queryParameters, IList results) en d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\SessionImpl.cs:línea 2052
       en NHibernate.Impl.SessionImpl.List(NativeSQLQuerySpecification spec, QueryParameters queryParameters, IList results) en d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\SessionImpl.cs:línea 2035
       en NHibernate.Impl.SessionImpl.List[T](NativeSQLQuerySpecification spec, QueryParameters queryParameters) en d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\SessionImpl.cs:línea 2021
       en NHibernate.Impl.SqlQueryImpl.List[T]() en d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\SqlQueryImpl.cs:línea 163
       en PigCsharp.forms.FrmMDIExpedientacion.FrmMDIExpedientacion_Load(Object sender, EventArgs e) en C:\Code\PigCsharp\PigCsharp\forms\frmMDIExpedientacion.cs:línea 778
       en System.Windows.Forms.Form.OnLoad(EventArgs e)
       en System.Windows.Forms.Form.OnCreateControl()
       en System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       en System.Windows.Forms.Control.CreateControl()
       en System.Windows.Forms.Control.WmShowWindow(Message& m)
       en System.Windows.Forms.Control.WndProc(Message& m)
       en System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       en System.Windows.Forms.Form.WmShowWindow(Message& m)
       en System.Windows.Forms.Form.WndProc(Message& m)
       en System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       en System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       en System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       en System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, Int32 wParam, Int32 lParam)
       en System.Windows.Forms.Form.SetVisibleCore(Boolean value)
       en System.Windows.Forms.Control.set_Visible(Boolean value)
       en System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       en System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       en System.Windows.Forms.Application.Run(Form mainForm)
       en PigCsharp.forms.submain.Main() en C:\Code\PigCsharp\PigCsharp\main\submail.cs:línea 29
       en System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       en System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       en Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       en System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       en System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       en System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       en System.Threading.ThreadHelper.ThreadStart()
  InnerException: MySql.Data.MySqlClient.MySqlException
       Message=Fatal error encountered during command execution.
       Source=MySql.Data
       ErrorCode=-2147467259
       Number=0
       StackTrace:
            en MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
            en MySql.Data.MySqlClient.MySqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
            en System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
            en NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd) en d:\CSharp\NH\NH\nhibernate\src\NHibernate\AdoNet\AbstractBatcher.cs:línea 247
            en NHibernate.Loader.Loader.GetResultSet(IDbCommand st, Boolean autoDiscoverTypes, Boolean callable, RowSelection selection, ISessionImplementor session) en d:\CSharp\NH\NH\nhibernate\src\NHibernate\Loader\Loader.cs:línea 1349
            en NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) en d:\CSharp\NH\NH\nhibernate\src\NHibernate\Loader\Loader.cs:línea 413
            en NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) en d:\CSharp\NH\NH\nhibernate\src\NHibernate\Loader\Loader.cs:línea 243
            en NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) en d:\CSharp\NH\NH\nhibernate\src\NHibernate\Loader\Loader.cs:línea 1694
       InnerException: MySql.Data.MySqlClient.MySqlException
            Message=Parameter '@iParameter' must be defined.
            Source=MySql.Data
            ErrorCode=-2147467259
            Number=0
            StackTrace:
                 en MySql.Data.MySqlClient.Statement.SerializeParameter(MySqlParameterCollection parameters, MySqlPacket packet, String parmName)
                 en MySql.Data.MySqlClient.Statement.InternalBindParameters(String sql, MySqlParameterCollection parameters, MySqlPacket packet)
                 en MySql.Data.MySqlClient.Statement.BindParameters()
                 en MySql.Data.MySqlClient.PreparableStatement.Execute()
                 en MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
            InnerException:


please can you help me.

Regards
Posted
Updated 6-Oct-11 22:35pm
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900