Hola a Todos... de ante mano agradezco mucho la ayuda....
 
Estoy comenzando con NHibernet y tengo un problema que no he podido resolver,
en varios días. Estoy utilizando las siguientes versiones:
 
- NHibernate-1..2.0.GA.msi
- Mysql - mysql-5.0.13-rc-win32
- Microsoft Visual C# 2005 Esp.
 
Les detallo el error:
 
a) Seguí los pasos indicados en el siguiente articulo:
http://www.hibernate.org/362.html
 
b) En los post del articulo, una persona hace referencia a las consideraciones 
para usar
Nhibernet con MySql. Probé utilizando esas opciones también.
 
c) Los siguientes son los archivos de configuración que tengo en mi proyecto.
 
1.- hibernate.cfg.xml
 
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<!-- Add this element -->
<configSections>
<section
name="hibernate-configuration"
type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"
/>
</configSections>
<!-- properties -->
<property name="dialect">NHibernate.Dialect.MySQL5Dialect</property>
<property 
name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property 
name="connection..driver_class">NHibernate.Driver.MySqlDataDriver</property> 
<property 
name="connection.connection_string">Server=localhost;Database=sparkempi;User 
ID=Core;Password=qwes;CharSet=utf8</property>
<!-- mapping files -->
<mapping resource="MysqlHibernet.User.hbm.xml" assembly="MysqlHibernet"/>
<!-- assambly mapping -->
<mapping assembly="MysqlHibernet"/>
</session-factory>
</hibernate-configuration>
</configuration>
 
2.- User.hbm.xml
 
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" 
assembly="MysqlHibernet" namespace="MysqlHibernet.Clases">
<class name="User, MysqlHibernet" table="Users" lazy="false">
<id name="Id" column="LogonId" type="String" length="20">
<generator class="assigned" />
</id>
<property name="UserName" column="Name" type="String" length="40"/>
<property name="Password" column="Password" type="String" length="20"/>
<property name="EmailAddress" column="EmailAddress" type="String" length="40"/>
<property name="LastLogon" column="LastLogon" type="DateTime"/>
</class>
</hibernate-mapping>
 
3.- User.cs
 
using System;
using System.Collections.Generic;
using System.Text;
using NHibernate.Cfg;
namespace MysqlHibernet.Clases
{
public class User
{
private string id;
private string userName;
private string password;
private string emailAddress;
private DateTime lastLogon;
public User()
{
}
public virtual string Id
{
get { return id; }
set { id = value; }
}
public string UserName
{
get { return userName; }
set { userName = value; }
}
public string Password
{
get { return password; }
set { password = value; }
}
public string EmailAddress
{
get { return emailAddress; }
set { emailAddress = value; }
}
public DateTime LastLogon
{
get { return lastLogon; }
set { lastLogon = value; }
}
}
}
 
4.- Con el siguiente código estoy intentando crear la conexiónc con Hibernet y 
la clase para guardar un registro de prueba.
 
private void FormMain_Load(object sender, EventArgs e)
{
NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();
cfg.AddAssembly("MysqlHibernet");
cfg.Configure("hibernate.cfg.xml");
ISessionFactory Sessionfactory = cfg.BuildSessionFactory();
ISession CurrentSession = Sessionfactory.OpenSession();
ITransaction transaction = CurrentSession.BeginTransaction();
// create the user class
User newUser = new User();
newUser.Id = "joe_cool";
newUser.UserName = "Joseph Cool";
newUser.Password = "abc123";
newUser.EmailAddress = "[EMAIL PROTECTED]";
newUser.LastLogon = DateTime.Now;
// Tell NHibernate that this object should be saved
MessageBox.Show(Convert.ToString(CurrentSession.IsConnected));
CurrentSession.Save(newUser);
// commit all of the changes to the DB and close the ISession
transaction.Commit();
CurrentSession.Close();
}
 
e) El siguiente es el error que objento en la línea 
"cfg.AddAssembly("MysqlHibernet")".
 
Could not compile the mapping document: MysqlHibernet.User.hbm.xml
No se controló NHibernate.MappingException
  Message="Could not compile the mapping document: MysqlHibernet.User.hbm.xml"
  Source="NHibernate"
  StackTrace:
       at NHibernate.Cfg.Configuration.LogAndThrow(MappingException me)
       at NHibernate.Cfg.Configuration.AddValidatedDocument(XmlDocument doc, 
String name)
       at NHibernate.Cfg.Configuration.AddXmlReader(XmlTextReader hbmReader, 
String name)
       at NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream, 
String name)
       at NHibernate.Cfg.Configuration.AddResource(String path, Assembly 
assembly)
       at NHibernate.Cfg.Configuration.AddResources(Assembly assembly, IList 
resources, Boolean skipOrdering)
       at NHibernate.Cfg.Configuration..AddAssembly(Assembly assembly, Boolean 
skipOrdering)
       at NHibernate.Cfg.Configuration.AddAssembly(Assembly assembly)
       at NHibernate.Cfg.Configuration.AddAssembly(String assemblyName)
       at MysqlHibernet..Clases.FormMain.FormMain_Load(Object sender, EventArgs 
e) in 
D:\EMPI_CVS\Develop\SourceCode\Examples\PM\Hibernet\MysqlHibernet\MysqlHibernet\FormMain..cs:line
 26
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, 
Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, 
Int32 nCmdShow)
       at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
       at System.Windows..Forms.Form.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Control.set_Visible(Boolean value)
       at 
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 
reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 
reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at MysqlHibernet.Clases.Program.Main() in 
D:\EMPI_CVS\Develop\SourceCode\Examples\PM\Hibernet\MysqlHibernet\MysqlHibernet\Program.cs:line
 17
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence 
assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext 
executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
}
 
--------------------------------------------------------
Muchas gracias...!!!
 
;-)




Sé un Mejor Amante del Cine
¿Quieres saber cómo? ¡Deja que otras personas te ayuden! .







Sé un Mejor Amante del Cine
¿Quieres saber cómo? ¡Deja que otras personas te ayuden! .


       
____________________________________________________________________________________
Sé un Mejor Amante del Cine                         
¿Quieres saber cómo? ¡Deja que otras personas te ayuden!
http://advision.webevents.yahoo.com/reto/entretenimiento.html
--~--~---------~--~----~------------~-------~--~----~
Para escribir al Grupo, hágalo a esta dirección: 
[email protected]
Para más, visite: http://groups-beta.google.com/group/NHibernate-Hispano
-~----------~----~----~----~------~----~------~--~---

Responder a