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: disconnected after query.List()
PostPosted: Mon Sep 11, 2006 10:37 am 
Newbie

Joined: Fri Sep 01, 2006 8:45 am
Posts: 9
Hello.

After query.List() my session is disconnected. Is it a bug?

my code:
Code:
        public object GetById(Type typeToGet, int valueId)
        {
            _session.Reconnect();
            object result;
           
            try
            {
                NHibernate.IQuery query = _session.CreateQuery("");
               
                switch (typeToGet.Name)
                {
                    case "Customer":
                        query = _session.CreateQuery("from Customer as cus where cus.CustomerId = ?");
                        break;
                    case "Contract":
                        query = _session.CreateQuery("from Contract as con where con.ContractId = ?");
                        break;
                }

                query.SetInt32(0, valueId);

                try
                {
                    Console.WriteLine("1:" + _session.IsConnected);
                    result = query.List()[0];
                    Console.WriteLine("2:" + _session.IsConnected);
                }
                catch (ArgumentOutOfRangeException)
                {
                    throw new NHibernate.ObjectNotFoundException(valueId, typeToGet);
                }
            }
            finally
            {
                _session.Disconnect();
            }

            return result;
        }


in the second try{} between Console.WriteLine("1:" + _session.IsConnected) and Console.WriteLine("2:" + _session.IsConnected) the connection is lost. Result is not empty and it appears no exception. How can it be? Can anyone help me?

regards
kesch


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.