These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: cannot make nHibernate work :(
PostPosted: Thu Apr 17, 2008 2:31 pm 
Newbie

Joined: Sat Mar 22, 2008 7:56 pm
Posts: 2
Hello,

I try out nHibernate for the first time, and I am unable to make it work !

I use VS 2008, VB.NET and nHibernate 1.2.1

I created a ConsoleApp with this code :


Imports NHibernate.Cfg
Imports NHibernate


Module Module1

Sub Main()
Dim cfg As New NHibernate.Cfg.Configuration()
cfg.AddAssembly("testNHibernate99")
Dim factory As ISessionFactory = cfg.BuildSessionFactory()
Dim session As ISession = factory.OpenSession()
Dim elements = session.CreateCriteria(GetType(testNHibernate99.Element)).List(Of testNHibernate99.Element)()
End Sub

End Module


Public Class Element
Private _Id As Integer
Private _Keyword As String
Public Property Id() As Integer
Get
Return _Id
End Get
Set(ByVal value As Integer)
_Id = value
End Set
End Property
Public Property Keyword()
Get
Return _Keyword
End Get
Set(ByVal value)
_Keyword = value
End Set
End Property
End Class





my app.config goes like this :

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="WordDocPromoNew.Settings1" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<nhibernate>
<add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
<add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2005Dialect"/>
<add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver"/>
<add key="hibernate.connection.connection_string" value="Server=server;Database=mydb;uid=sa;pwd=xxxx;"/>
<add key="hibernate.show_sql" value="true" />
</nhibernate>
</configuration>




and I embended as a resource a file called Element.hbm.xml that contains this :

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="testNHibernate99" assembly="testNHibernate99">
<class name="Element">
<id name="Id">
<generator class="assigned" />
</id>
<property name="Keyword" />
</class>
</hibernate-mapping>



When I run the project I get the following error on the line
Dim factory As ISessionFactory = cfg.BuildSessionFactory()

error :
{"property mapping has wrong number of columns: Element.testNHibernate99.Element type: Object"}

Thanks a lot for any help on this problem !

Regards,
Fabianus


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 17, 2008 5:18 pm 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
I think the datatype is missing on the Keyword property. Try

Code:
Public Property Keyword() as String

_________________
--Wolfgang


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.