-->
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.  [ 3 posts ] 
Author Message
 Post subject: Attempting Object-Model First Design
PostPosted: Tue Feb 06, 2007 2:57 pm 
Newbie

Joined: Tue Feb 06, 2007 2:51 pm
Posts: 2
Hello everyone,

I'm attempting to get NHibernate integrated into an existing product that has LOTS of tiny classes that need to be persisted to a data layer. Our implementation needs to be database independent as well. I've been trying to get net2hbm and hbm2ddl working, without success even for the simplest of examples. The errors are all being reported under hbm2ddl. I was wondering if I could get some feedback on what is going on.

Hibernate version: NHibernate 1.0.4

Mapping documents:
<?xml version="1.0" encoding="utf-8"?>
<!--Generated from NHibernate.Mapping.Attributes on 2007-02-06 12:00:54Z.-->
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="NHibernateEval.Person, NHibernateEval">
<id>
<generator class="native" />
</id>
<property name="FirstName" not-null="true "/>
<property name="LastName" not-null="true "/>
<property name="Birthday" not-null="true "/>
<property name="MetricHeight" not-null="true" />
<property name="MetricWeight" not-null="true" />
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
public void GenerateSqlSchema(string _outputFilename) {
ISessionFactory factory = null;

foreach (string filename in AssemblyFilenames)
{
Assembly asm = Assembly.LoadFrom(filename);
Console.WriteLine("Attempting to load Assembly {0}", filename);
using(Stream s = new MemoryStream())
{
HbmSerializer.Default.Serialize(s, asm);
s.Position = 0;
m_Configuration.AddInputStream(s);
}
}
factory = m_Configuration.BuildSessionFactory();

SchemaExport se = new SchemaExport(m_Configuration);
se.SetOutputFile(_outputFilename);
se.Create(false, false);
}

Full stack trace of any exception that occurs:
Unhandled Exception: NHibernate.MappingException: must specify an identifier type: Person
at NHibernate.Cfg.Binder.BindRootClass(XmlNode node, RootClass model, Mappings mappings)
at NHibernate.Cfg.Binder.BindRoot(XmlDocument doc, Mappings model)
at NHibernate.Cfg.Configuration.AddValidatedDocument(XmlDocument doc)
at NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream)

Name and version of the database you are using:
SqlServer 2000

The generated SQL (show_sql=true):
none. exception thrown first :(

Debug level Hibernate log excerpt:
NONE


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 06, 2007 11:29 pm 
Beginner
Beginner

Joined: Mon Jan 08, 2007 11:59 pm
Posts: 31
Code:
<id>
<generator class="native" />
</id>

you would have to specify at least the name of the ID column.

Job Samuel


Top
 Profile  
 
 Post subject: Boooo
PostPosted: Wed Feb 07, 2007 12:48 pm 
Newbie

Joined: Tue Feb 06, 2007 2:51 pm
Posts: 2
Well, the Name="" in my NHMA decorator for the Id property was needed, but also a Type="Int64" really made the error go away.

Thanks for the help!


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