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: Changing the IList return type from ICriteria.List()
PostPosted: Thu Jun 01, 2006 9:00 am 
Newbie

Joined: Wed May 31, 2006 7:47 am
Posts: 6
Is there a way to change the list return type from a ICriteria.List() call? I noticed that ICriteria calls ISession.Find() and those methods have a hardcoded ArrayList being created for the return value.

Is there another way to use ICriteria so that I can specify my own List return type that adhere's to the IList interface? Perhaps a ISession property or a ISessionFactory configuration variable?

I could write a quick util or subclass to change list types for my application but I was hoping a nice configuration change could help here. I want to use a custom list type that facilitates various types of object management e.g. the list keeps track of deletes and queues them up for ISession.Delete()s when accept the changes to the list.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 01, 2006 11:35 am 
Beginner
Beginner

Joined: Tue May 30, 2006 10:55 am
Posts: 21
Well, it is quite simple. Try this:
Code:
internal YourTypedCollection GetAllTypedObjects()
{
   //create new typed collection
   YourTypedCollection collection = new YourTypedCollectionn();
   try
   {
      //open session
      ISession session = factory.OpenSession();
      //define HQL statement for getting all activated bidders   collection.AddRange(session.CreateCriteria(typeof(TypedObjectClass)).List());
      //close session
      session.Close();
   }
   catch(Exception ex)
   {
      Debug.WriteLine(ex.Message);
   }
   //return the filled collection
   return collection;
}


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.