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.  [ 1 post ] 
Author Message
 Post subject: To Flush() or not to Flush()
PostPosted: Fri Sep 04, 2009 11:35 am 
Newbie

Joined: Tue Sep 01, 2009 5:00 pm
Posts: 3
First, thank you everyone for all your help... I'm quickly getting NHibernate, but still have many questions. Currently I am writing some unit tests against a DAO, but in order for the test to succeed, I need to slip in a call to Flush() after setting up my data. Let me explain...

TEST(){

// #1
foolist = CreateFooList(5);

// #2
foolist[0].Active = false;
foolist[1].Active = false;

// #3
activeFooList = GetActiveFoos();

// #4
Asserts

}

#1
My test begins by creating a number of Foo objects, and saving them.

#2
I then take a subset of the list of Foo objects and set the Active property to false.

#3
At this point, I have verified that 2 out of the 5 Foo objects have the Active property set to false. I then query to get all Active Foo objects via a NHibernate Criteria object.

#4
I assert that the length of activeFooList is 3 and that all items within the list have the Active property set to true. The problem is, activeFooList has a length of 5 and all items within the list have the Active property set to true, yet I expected two to have it set to False. Unless I make a call to Flush(); after setting the two Foo object to "inactive" this test fails. Since I am using one session during the entire scope of the test, I don't understand why I need the call to Flush(). Am I missing something?

Thanks!
Bryan


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.