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.  [ 6 posts ] 
Author Message
 Post subject: Some questions about nhibernate
PostPosted: Thu Aug 31, 2006 1:55 am 
Newbie

Joined: Wed Aug 30, 2006 4:43 am
Posts: 4
Hi !

I'm a beginner with nhibernate and i try to use it in one of my projects. I get some trouble because my business class was not visible outside of my assembly. I accessed to them thanks to interface.
My first question is the following :
    Is it possible to persist object defined by an interface ?

To avoid this, I changed the visibility of my business classes. Then i tried to create my hbm.xml files and i'm using some attributes that i don't understand :
    cascade
    inverse
    lazy

My second question :

    Is it possible to explain me what these attributes really do ?


Thanks in advance

Vincent.

PS : I'm using v1.2 Alpha1


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 31, 2006 3:44 am 
Newbie

Joined: Wed Aug 16, 2006 2:49 am
Posts: 14
I guess it would be wise to consult the documentation for those attributes http://nhibernate.sourceforge.net/nh-do ... ation.html


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 31, 2006 4:16 am 
Newbie

Joined: Wed Aug 30, 2006 4:43 am
Posts: 4
Yes I've already printed it but i can't find a clear definition of these terms.
Here is what i found for "cascade" :
Quote:
Specifies which operations should be cascaded from the parent object to the associated object

What does 'cascaded' mean ?

For inverse :
Quote:
You may specify a bidirectional many-to-many association simply by mapping two many-to-many associations to the same database table and declaring one end as inverse (which end is your choice).

What is an end of bidirectionnal association ... If it is bidirectionnal, there is no end ?

....


And i didn't find anything about interface. Is it possible de make it persistent ?

Thanks,

Vincent.[/quote]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 01, 2006 2:17 am 
Senior
Senior

Joined: Mon Aug 21, 2006 9:18 am
Posts: 179
"Cascade" is essentially a strategy you choose for persisting the Object Graph in your entities. So if you have a Person class that has an IList of Phone objects, you only need to ISession.SaveOrUpdate(personObject) and the child objects will be persisted also (if you selected Cascade="all"). I

t is important for you to understand who "owns" a relationship in a bidirectional relationship. In our example, "Person" would either .Add or .Remove the Phone objects to its Phones collection and so persist just fine. If you tried to simply make Person = personObject within your Phone object, you'll get an exception because Phone isn't the owner on the relationship.

You don't persist interfaces per se since they obviously don't hold values...they are contracts. The implementations of those interfaces are what are persisted.

Hope this helps
MIKE


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 02, 2006 12:44 pm 
Newbie

Joined: Wed Aug 30, 2006 4:43 am
Posts: 4
Thanks a lot for your help :)

Vince.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 02, 2006 4:28 pm 
Senior
Senior

Joined: Mon Aug 21, 2006 9:18 am
Posts: 179
Youre welcome!

_________________
If this helped...please remember to rate it!


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