Anyone use NHibernate?
New Community Forums available at http://forums.ext.net
 

Coolite Forums

Welcome Guest ( Login | Register )
 
Anyone use NHibernate?
Subscribe
Last Login: 6/17/2010 4:30:38 PM
Posts: 1,239,
Posted 6/13/2009 1:51:27 PM

Group: Coolite Premium Member & Early Adopter
(Unrelated to Coolite development)

Hello,

Anyone on the board use NHibernate? I'm wondering if anyone here has done the following:

https://forum.hibernate.org/viewtopic.php?f=25&t=997570

If you have any experience doing something similar, I'm trying to avoid using stored procs.0

Cheers,
Timothy


----
Timothy Grant Vogelsang
tvogelsang [at] esolutionsgroup [dot] ca
Project Manager / Senior Software Developer
Microsoft .NET Framework 3.5
Coolite Toolkit 1.0

Last Login: 7/5/2010 8:29:46 AM
Posts: 427,
Posted 6/14/2009 1:45:58 AM

Group: Coolite Premium Member & Early Adopter
 Hi Timothy,

If I correctly understood you need a hierarchical table with a field pointing to the id of the same table.
I think the structure should be:

Employee

 - ID
 - NAME
 - ROLE
 - PARENT_ID

don't remember how it works in Nhibernate, but in the entity class I would add a method that retrieves the children items,
and one retrieving the parent item.



public function List<Employee> GetChildren()
{
     // return emplyees with parent_id = this.id
}

public function Employee GetParent(int id)

{

     // return emplyee with parent_id = id

}

// it could be:


public function ILIst GetChildren()
{    
       IList employees = sess.CreateCriteria(typeof(Employee))
       .Add(Expression.Eq("ParentId", this.id))
       .List();


return employees;
}



I read this: https://www.hibernate.org/hib_docs/nhibernate/html/querycriteria.html

Then I would build the tree with a recursive function.

Is it helpfull for you?

Matteo
« Prev Topic | Next Topic »
Reading This Topic
Active Users: 0 ( 0 guests, 0 members, 0 anonymous members )
No members currently viewing this topic.
All times are GMT -5:00, Time now is 10:01pm