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: NHibernate Attribute mapping documenation
PostPosted: Fri Jul 14, 2006 11:41 am 
Newbie

Joined: Sat Jun 17, 2006 12:43 pm
Posts: 5
Hi All,

Is there any place where I can find documentation for using Attributes to map relations in NHibernate.

I m *grr* a newbie to NHibernate and been working for under a month. I find using .hbm files pretty easy, but want to move to using decorating classes with attribitues that do the mapping.

If anyone has any example and also how to start using them, like invoke them etc., please provide me with the relevant link.

The main things I would like to know are

declaring a class as persistant
1-1 mapping
1-many mapping
many-1 mapping
id
property
cascade

And also, is there any way i can get the intelli-sence to work with this? In some other place, i was suggested to copy a few schema files into .net shema directory

Many thanks

Sath


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 15, 2006 2:30 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
NHibernateEg may be a good start: http://nhibernate.sourceforge.net/NHibernateEg/

Note that the mapping with .NET attributes is similar with the mapping with XML; so if you read a mapping done in XML, you should be able to easily convert it in .NET attributes.

Here is a page refering to most articles/tutorials/samples/tools available on NHibernate: http://hibernate.org/365.html

And don't forget the official documentation of NHibernate.Mapping.Attributes: http://www.hibernate.org/hib_docs/nhibernate/html/mapping-attributes.html (it contains many useful tips...)

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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 17, 2006 10:24 am 
Beginner
Beginner

Joined: Tue Jan 17, 2006 12:55 pm
Posts: 49
Personally, I'd prefer to keep my Entities totally agnostic about the data storage mechanism, which would mean the old school approach of using a seperate mapping assembly rather than embedding the mapping in your enties using attributes.

My viewpoint is that my current project requires that the repositories/data layer should be swappable for any data access that my project sponsors would wish to use in future... If this is not a concern, go ahead if you think it would make life easier.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 17, 2006 10:49 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
My viewpoint is that .NET attributes are more like documentation than code; they do not influence your classes and you aren't forced to use them.

Note that it is recommended (in production) to generate (and save) a hbm.xml mapping file from the attributes (once the mapping no longer changes); and use this file to configure NHibernate; it will be slightly faster.

_________________
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.