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.  [ 3 posts ] 
Author Message
 Post subject: Simple Questions
PostPosted: Fri Dec 12, 2008 3:49 am 
Newbie

Joined: Sat Jun 10, 2006 10:24 am
Posts: 16
Hi NH people,

Couple Simple NH questions,

Only just started using NH, the version I'm using is 2.0.1GA with dotnet 3.5

1. Which method do caching apply to? from the docoumentation (14.5):

"Whenever you pass an object to Save(), Update() or SaveOrUpdate() and whenever you retrieve an object using Load(), Find(), Enumerable(), or Filter()"

Does that not include result sets fetch via CreateQuery Or Using CreateCriteria?


2. What is the best way to delete a collection of entities when I have an array ints representing ids (int[])?


3. Is there a way to fetch a subset of an objects fields and still return it the object.

eg (none of the details here are real just an example),

Table TestEntity
id int
name varchar(20)
item1 varchar(20)
value2 varchar(20)


IQuery Q = UnitOfWork.CurrentSession.CreateQuery("SELECT T.Id, T.Name FROM TestEntity AS T");
Q.List<TestEntity>()

When ever I try that I recieve this error: "The value \"System.Object[]\" is not of type \"Domain.TestEntity\" and cannot be used in this generic collection.\r\nParameter name: value"


4. When I create a query such as the above in question 3, is there a way to obtain metadata about the types and column names returned from the query?

so for above query I would like to end up with:

Id, system.Int
Name, System.string

5. Whats the best way to handle entities in a disconnected WCF situation, I'm using DTO and mapping them it seems to work, just wondered if anyone had better ways to handle it (maybe using the entities natively)?

Thanks!
Maxus


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 23, 2008 9:01 pm 
Newbie

Joined: Sat Jun 10, 2006 10:24 am
Posts: 16
Hi NH People,

I have solved the first one, appreanlty the Load(), Find(), Enumerable(), or Filter() are deprecated, and replaced with CreateQuery Or Using CreateCriteria so those are cached.

Still dont know the anwers to the others, can anyone provides some hints or answers?

Thanks!
M


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 02, 2009 1:29 am 
Newbie

Joined: Sat Jun 10, 2006 10:24 am
Posts: 16
Hi People,

I found the answer to my third issue:

Use a result transformer:

Q.SetResultTransformer(new NHibernate.Transform.AliasToBeanResultTransformer(typeof(TestEntity)));

Thought this might help out others.

Thanks!
M


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