-->
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.  [ 4 posts ] 
Author Message
 Post subject: Additional information: The 'Type' attribute is not declared
PostPosted: Wed Dec 21, 2005 1:25 pm 
Newbie

Joined: Wed Dec 21, 2005 1:18 pm
Posts: 3
I have search for this thread, or a similar one, and not found one. So...
I am new to nHibernate, and have been attempting to set up the QuickStart example with no luck. I keep getting this error:

An unhandled exception of type 'NHibernate.MappingException' occurred in nhibernate.dll
Additional information: The 'Type' attribute is not declared. An error occurred at , (7, 43).

I am running it in a simple console application. Here is the class:

using System;
using NHibernate;
using NHibernate.Cfg;
using DataObjects;

namespace NHibernateTest
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Configuration cfg = new Configuration();
cfg.AddAssembly( "DataObjects" );
//cfg.AddAssembly( typeof( DataObjects.User ).Assembly );
ISessionFactory factory = cfg.BuildSessionFactory();
ISession session = factory.OpenSession();
ITransaction transaction = session.BeginTransaction();

User newUser = new User();
newUser.Id = "joe_cool";
newUser.UserName = "Joseph Cool";
newUser.Password = "abc123";
newUser.EmailAddress = "joe@cool.com";
newUser.LastLogon = DateTime.Now;

// Tell NHibernate that this object should be saved
session.Save(newUser);

// commit all of the changes to the DB and close the ISession
transaction.Commit();
session.Close();
}
}
}



Here is my persistent object:
using System;
using System.Reflection;
namespace DataObjects
{
public class User
{
private string id;
private string userName;
private string password;
private string emailAddress;
private DateTime lastLogon;


public User()
{
}

public 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; }
}

}
}


and here is my User.hbm.xml file:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="DataObjects.User, DataObjects" table="users">
<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" type="String" length="20" />
<property name="EmailAddress" type="String" length="40" />
<property name="LastLogon" type="DateTime" />
</class>
</hibernate-mapping>



any help would be greatly appreciated.

_________________
dd


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 21, 2005 1:48 pm 
Newbie

Joined: Wed Dec 21, 2005 1:18 pm
Posts: 3
I wonder if it could be an issue with my DataObjects assembly. Unfortunately, I am not to familiar with assemblies.

_________________
dd


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 21, 2005 1:54 pm 
Newbie

Joined: Wed Dec 21, 2005 1:18 pm
Posts: 3
So I moved all my classes from the DataObjects library to the NHibernateTest library which is the namespace of my app, and still all I get are mapping errors!

_________________
dd


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 23, 2005 7:18 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
Can you post the full exception trace?

Note that:
Code:
cfg.AddAssembly( typeof( DataObjects.User ).Assembly );
is definitively safer.

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.