public void ObjectNotFound()
        {
            ISession sess = OpenSession();
            ITransaction tx = sess.BeginTransaction();

            Author author = new Author();
            author.Name = "Moo Cow";
            sess.Persist(author);

            tx.Commit();
            sess.Clear();
            IDbCommand statement = sess.Connection.CreateCommand();
            statement.CommandText = "DELETE FROM Author";
            statement.ExecuteNonQuery();

            IFullTextSession s = Search.CreateFullTextSession(sess);
            tx = s.BeginTransaction();
            QueryParser parser = new QueryParser("title", new KeywordAnalyzer());
            Lucene.Net.Search.Query query = parser.Parse("name:moo");
            IFullTextQuery hibQuery = s.CreateFullTextQuery(query, typeof(Author), typeof(Music));
            IList result = hibQuery.List();
            Assert.AreEqual(0, result.Count, "Should have returned no author");

            foreach (object o in result)
            {
                s.Delete(o);
            }

            tx.Commit();
            s.Close();
        }
        public void Criteria()
        {
            IFullTextSession s = Search.CreateFullTextSession(OpenSession());
            ITransaction tx = s.BeginTransaction();
            Book book = new Book(1, "La chute de la petite reine a travers les yeux de Festina", "La chute de la petite reine a travers les yeux de Festina, blahblah");
            s.Save(book);
            Author emmanuel = new Author();
            emmanuel.Name = "Emmanuel";
            s.Save(emmanuel);
            book.Authors.Add(emmanuel);
            tx.Commit();
            s.Clear();

            tx = s.BeginTransaction();
            QueryParser parser = new QueryParser("Title", new StopAnalyzer());

            Lucene.Net.Search.Query query = parser.Parse("Summary:Festina");
            IFullTextQuery hibQuery = s.CreateFullTextQuery(query, typeof(Book));
            IList result = hibQuery.List();
            Assert.NotNull(result);
            Assert.AreEqual(1, result.Count, "Query with no explicit criteria");
            book = (Book) result[0];
            //Assert.IsFalse(NHibernate.IsInitialized(book.Authors), "Association should not be initialized");

            result = s.CreateFullTextQuery(query).SetCriteriaQuery(s.CreateCriteria(typeof(Book)).SetFetchMode("Authors", FetchMode.Join)).List();
            Assert.NotNull(result);
            Assert.AreEqual(1, result.Count, "Query with no explicit criteria");
            book = (Book)result[0];
            //Assert.IsTrue(NHibernate.IsInitialized(book.Authors), "Association should be initialized");
            Assert.AreEqual(1, book.Authors.Count);

            // cleanup
            s.Delete("from System.Object");
            tx.Commit();
            s.Close();
        }
        public void EagerCollectionLoad()
        {
            ISession sess = this.OpenSession();
            ITransaction tx = sess.BeginTransaction();

            Music music = new Music();
            music.Title = "Moo Goes The Cow";
            Author author = new Author();
            author.Name = "Moo Cow";
            music.Authors.Add(author);
            sess.Persist(author);

            author = new Author();
            author.Name = "Another Moo Cow";
            music.Authors.Add(author);
            sess.Persist(author);

            author = new Author();
            author.Name = "A Third Moo Cow";
            music.Authors.Add(author);
            sess.Persist(author);

            author = new Author();
            author.Name = "Random Moo Cow";
            music.Authors.Add(author);
            sess.Persist(author);
            sess.Save(music);

            Music music2 = new Music();
            music2.Title = "The Cow Goes Moo";
            author = new Author();
            author.Name = "Moo Cow The First";
            music2.Authors.Add(author);
            sess.Persist(author);

            author = new Author();
            author.Name = "Moo Cow The Second";
            music2.Authors.Add(author);
            sess.Persist(author);

            author = new Author();
            author.Name = "Moo Cow The Third";
            music2.Authors.Add(author);
            sess.Persist(author);

            author = new Author();
            author.Name = "Moo Cow The Fourth";
            music2.Authors.Add(author);
            sess.Persist(author);
            sess.Save(music2);
            tx.Commit();
            sess.Clear();

            IFullTextSession s = Search.CreateFullTextSession(sess);
            tx = s.BeginTransaction();
            QueryParser parser = new QueryParser("title", new KeywordAnalyzer());
            Lucene.Net.Search.Query query = parser.Parse("title:moo");
            IFullTextQuery hibQuery = s.CreateFullTextQuery(query, typeof(Music));
            IList result = hibQuery.List();
            Assert.AreEqual(2, result.Count, "Should have returned 2 Music");
            music = (Music) result[0];
            Assert.AreEqual(4, music.Authors.Count, "Music 1 should have 4 authors");
            music = (Music) result[1];
            Assert.AreEqual(4, music.Authors.Count, "Music 2 should have 4 authors");

            // cleanup
            s.Delete("from System.Object");
            tx.Commit();
            s.Close();
        }