-->
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: Using Multiple .hbm files from different dlls
PostPosted: Sun May 18, 2008 1:41 pm 
Newbie

Joined: Sun May 18, 2008 1:21 pm
Posts: 13
Hello All,

I am new to NHibernate and badly stuck in a problem.

My Project is a web based application in which i am using NHibernate Mapping Attributes to generate my hbm file. Also I added a DLL of an existing Project with embeded hbm file of that project in it. All my reference tables are from that dll e.g Country, Booking Status etc and i am using version 1.0.2 with SQL Server 2005

My Dll names are :
1. AM.Library (new project dll)
2. EMSServerLib (old project dll)

My Question is:

How to write Mapping Attribute for reference tables which exist in some other dll.

I am writing this code to declare
[Set(0, Name = "OperatorSet", Lazy = false, Inverse = true)]
[Key(1, Column = "OperatorId")]
[OneToMany(2, Class = "EMS.Server.DataObjects.Operator, EMSServerLib")]

private EMS.Server.DataObjects.Operator m_operator;

public Operator Operator
{
get
{
return m_operator;
}
set
{
m_operator = value;
}
}

Quote:
The Generated HBM File look like this with auto import = false.

<?xml version="1.0" encoding="utf-8"?>
<!--Generated by NHibernate.Mapping.Attributes on 2008-05-18 22:34:42Z.-->
<hibernate-mapping default-access="field.camelcase-underscore" auto-import="false" xmlns="urn:nhibernate-mapping-2.0">

<class name="AM.Library.AMSurvey, AM.Library" table="AM_SeismicSurvey">
<id name="SurveyId" column="SurveyId">
<generator class="identity" />
</id>
<set name="OperatorSet" lazy="false" inverse="true">
<key column="OperatorId" />
<one-to-many class="EMS.Server.DataObjects.Operator, EMSServerLib" />
</set>
</class>
</hibernate-mapping>

and my exception is :

[TypeLoadException: Could not load type 'EMS.Server.DataObjects.Operator, EMSServerLib', check that type and assembly names are correct]
NHibernate.Util.ReflectHelper.ClassForName(String name) +124
NHibernate.Cfg.Binder.ClassForFullNameChecked(String fullName, String errorMessage) +27

[MappingException: associated class not found: EMS.Server.DataObjects.Operator, EMSServerLib]
NHibernate.Cfg.Binder.ClassForFullNameChecked(String fullName, String errorMessage) +77
NHibernate.Cfg.Binder.BindOneToMany(XmlNode node, OneToMany model, Mappings mappings) +55
NHibernate.Cfg.Binder.BindCollection(XmlNode node, Collection model, String className, String path, Mappings mappings) +378
NHibernate.Cfg.CollectionTypeSet.Create(XmlNode node, String prefix, String path, PersistentClass owner, Mappings mappings) +56
NHibernate.Cfg.Binder.PropertiesFromXML(XmlNode node, PersistentClass model, Mappings mappings) +205
NHibernate.Cfg.Binder.BindRootClass(XmlNode node, RootClass model, Mappings mappings) +2690
NHibernate.Cfg.Binder.BindRoot(XmlDocument doc, Mappings model) +609
NHibernate.Cfg.Configuration.AddValidatedDocument(XmlDocument doc) +96
NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream) +103
Csla.NHibernate.Cfg.BuildSessionFactory(String factoryCfg) +279
Csla.NHibernate.Cfg.AddNewKey(String key) +203
Csla.NHibernate.Cfg.CheckKeyInTable(String key) +63
Csla.NHibernate.Cfg.get_Item(String index) +42
Csla.NHibernate.Cfg.GetSessionFactory(String key) +63

Please Help!!!!!!!!!!!!!!!!!!!!!!!!!!!!



Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 19, 2008 2:27 am 
Regular
Regular

Joined: Thu Mar 06, 2008 5:06 am
Posts: 68
Try this line in your hibernate.cfg.xml:

Code:
<mapping assembly="name_of_assembly" />


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 19, 2008 4:38 am 
Newbie

Joined: Sun May 18, 2008 1:21 pm
Posts: 13
Thanks for the reply but it didnt work.

I am unable to make a OneToMany relation ship using NHibernate.Mapping.Attributes.OneToMany class programetically.


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.