Oi pessoas
Estava pesquisando sobre o Nhibernate e achei um exemplo bem legalzinho sobre.
O problema é que ele dá erro no momento de salvar uma pessoa.
Primeiro:
Gostaria de saber se este problema está relacionado com o fato de usar o SQL Server 7 ?
Segundo:
Estou colocando o código da inserção :
Dim cfg As New Cfg.Configuration
cfg.AddAssembly(
"VB")
Dim factory As ISessionFactory = cfg.BuildSessionFactory()
Dim session As ISession = factory.OpenSession()
Dim newUser As New User
newUser.Id = "joe_cool1"
newUser.UserName =
"Joseph Cool1"
newUser.Password =
"abc1231"
newUser.EmailAddress =
"joe@cool.com1"
newUser.LastLogon = DateTime.Now
session.Save(newUser) ' Nesse ponto acontece o erro: "Adoexception: Could not save object"
session.Close()
Aqui vai o código do user.hbm.xml:
<?
xml version="1.0" encoding="utf-8" ?>
<
hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<
class name="VB.User, VB" table="sai_users">
<
id name="Id" type="String" length="20">
<
generator class="assigned" />
</
id>
<
property name="UserName" type="String" length="40"/>
<
property name="Password" type="String" length="20"/>
<
property name="EmailAddress" type="String" length="40"/>
<
property name="LastLogon" type="DateTime"/>
</
class>
</
hibernate-mapping>
E agora vai o código do app.config:
<?
xml version="1.0" encoding="utf-8" ?>
<
configuration>
<
configSections>
<
section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.3300.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</
configSections>
<
nhibernate>
<
add
key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvider"
/>
<
add
key="hibernate.dialect"
value="NHibernate.Dialect.MsSql2000Dialect"
/>
<
add
key="hibernate.connection.driver_class"
value="NHibernate.Driver.SqlClientDriver"
/>
<
add
key="hibernate.connection.connection_string"
value="Provider=SQLNCLI.1;Password=teste;Persist Security Info=True;User ID=teste;Initial Catalog=teste_user;Data Source=MATRIX"
/>
</
nhibernate>
</
configuration>
Preciso que isso funcione ou pelo menos uma resposta do porque isso não da certo, para decidir se devo mesmo usar o nhibernate ou não.
Grata
Fabi