-->
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.  [ 7 posts ] 
Author Message
 Post subject: Dynamic Instantiation
PostPosted: Mon Aug 01, 2005 4:44 pm 
Newbie

Joined: Mon Aug 01, 2005 4:33 pm
Posts: 4
hi all,

is there a special syntax for taking advantage of the dynamic instantiation feature of nhibernate? i'm new to the .net platform but it is my understanding that a scoping assembly should be required. it looks like this feature is implemented as i always run into a class not found when attempting to list the query with a the qualified class name (minus the assembly).

tia,
sean


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 01, 2005 8:32 pm 
Newbie

Joined: Mon Aug 01, 2005 4:33 pm
Posts: 4
just a quick follow up so others understand the concept here. dynamic instantiation from "hibernate in action" is hql that contains a "select new" clause. for example from the user guide:

-----------
select new Family(mother, mate, offspr)
from DomesticCat as mother
join mother.mate as mate
left join mother.kittens as offspr

assuming that the class Family has an appropriate constructor.
-----------

i've used this in the java version and wish to use this feature in c# however i continue to receive class not found errors. any help would be appreciated.

thanks
sean


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 04, 2005 7:23 pm 
Beginner
Beginner

Joined: Wed Jun 29, 2005 10:40 am
Posts: 30
Location: denver, co
You need to place an <import ...> element in one of your mapping files, like this:

Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
  <import class="Full.Namespace.And.ClassName, Assembly" rename="ClassName"/>
...
...
</hibernate-mapping>


Now you can use dynamic instantiation in yuor hql queries!


Top
 Profile  
 
 Post subject: thanks a bunch...
PostPosted: Thu Aug 04, 2005 8:52 pm 
Newbie

Joined: Mon Aug 01, 2005 4:33 pm
Posts: 4
i wasn't using a named query. thanks

sean


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2005 10:24 am 
Beginner
Beginner

Joined: Wed Jun 29, 2005 10:40 am
Posts: 30
Location: denver, co
You don't have to use a named query. All you need is that <import...> tag in one of your mapping files (to tell nhibernate "I will be using this class in queries"), and then you can use the class in any hql statement you want.


Top
 Profile  
 
 Post subject: ok
PostPosted: Fri Aug 05, 2005 6:50 pm 
Newbie

Joined: Mon Aug 01, 2005 4:33 pm
Posts: 4
thanks i'll add the import__and__make use of a named query. after working with both hiberate 2 & 3 over the past year and a half i must say i'm pretty impressed with where hnibernate is wrt the version 2 feature set. now if only the spring.net guys had the aop, txn interceptors and of course the nhibernate template features i'd be all set ;)

thanks for the help!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 02, 2005 4:24 pm 
Hiya

The Spring.NET team are actively investigating / working on the data access library of Spring.NET... this will include NHibernate support of course, including the cool usage promoted by the HIbernateTemplate from Spring Java. iBatis.NET is also to be supported in case you're interested ;)

Ciao
Rick


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