-->
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.  [ 2 posts ] 
Author Message
 Post subject: Named Querys - Is it possible in nHibernate
PostPosted: Mon Jan 02, 2006 5:56 pm 
Regular
Regular

Joined: Fri Nov 04, 2005 12:37 pm
Posts: 81
In my previous employment I used Hibernate in combination with Spring but now i ham using nHibernate as I am doing some .net work, and i am having some problems keeping my .net DAOs as clean as my Java ones were.

As my knowlegde of both Hibernate\Spring and nHibernate is average at best i just want to check if i could be doing things in a simulare way as i did in Java

Basically in my Java apps i would have a BaseDAO (which extended HibernateDaoSupport from the SpringFramework) which would handle all the main interactions with Hibernate it would have generic add, delete, update, and find fuctions, which my specfic objectDAOs could call.

So far i have pretty much followed this using c#.net, without the spring elements, and have made generic create and update functions in my BaseDAO, but im a litte stuck when it comes to the find funtionlity......there does not seem to be a generic way of using this. In the Java world i would use named queries in my mapping file with '?' in the hql where i wanted the parameters, i would then pass the named query and the params to the BaseDAO and it would do the work. As there are no named queries? im a little stuck....could i progress in a different way?


Top
 Profile  
 
 Post subject: GetNamedQuery workd in NHibernate as well.
PostPosted: Wed Jan 04, 2006 8:25 am 
Regular
Regular

Joined: Tue Jan 03, 2006 7:21 am
Posts: 85
I think you can work with Named Queries in NHibernate as well. just add the HQL query in the mapping doc as
<query
name='AnyQuery'>
from MarriedMan as mm where mm.Wife.Name='Relin'
</query>

and then you can call the GetNamedQuery method of the session object to get the IQuery interface which you can then execute.

So I think Named Queries do work in NHibernate.

Job Samuel.


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