You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by Greg Jackman <Gr...@nycity.com> on 2007/02/08 05:11:14 UTC

Re: Writing a custom session store by implementing ISessionStore

Hi Zarar

 

I'm experiencing similar problems to those that you had a whole ago,
relating to HttpContext being null (see thread below).

 

My situation as follows:

I'm using IBatis (DataAccess and DataMapper) to access my database. I am
trying to use the same code inside an asp website, as the back end of a
web service and as the data access for a windows app.

 

This was all working fine, until I tried to add support for
SqlDependency callbacks. SqlDependencies call back to the code in a
different thread, and it seems in the ASP version of my app, that the
HttpContext is missing, when I try to access data during a callback.

 

I was wondering if you found a good solution to the problem? Did you end
up implementing a new ISessionStore?

 

Any advice on how to proceed would be much appreciated,

 

Thanks,

Greg

 

 

 

 

 

 


Re: Writing a custom session store by implementing ISessionStore


Zarar Siddiqi
Mon, 09 Oct 2006 11:48:28 -0700

I'll go with this solution then.  Thank you very much.
 
Zarar
 
 
On 10/9/06, Gilles Bayon <[EMAIL PROTECTED]> wrote:
A CallContextSessionStore is not 100% safe in web environnement.
 
A better solution in your thread code is :
 
MyBackgroundCodeTask()
{
   IDalSession session = sqlMapper.CreateSqlMapSession();
   session.OpenConnection();
   IMappedStatement myStatement = GetMappedStatement("statementName",
parameterObject);
 
  ... myStatement.ExecuteQueryForObject(session, parameterObject);
 
  session.CloseConnection();
 
}
 
 
--
Cheers,
Gilles
 
<a href="http://www.amazon.com/gp/registry/6JCP7AORB0LE"
<http://www.amazon.com/gp/registry/6JCP7AORB0LE%22> ;>Wish List</a>
 

 


RE: Writing a custom session store by implementing ISessionStore

Posted by Greg Jackman <Gr...@nycity.com>.
Hi Gilles,

 

No problem on that. Thanks for all the help with the problem and all the
work on a great product! Everything is working fine now.

 

Cheers,

Greg

 

________________________________

From: Gilles Bayon [mailto:ibatis.net@gmail.com] 
Sent: Saturday, 10 February 2007 11:11 p.m.
To: user-cs@ibatis.apache.org
Subject: Re: Writing a custom session store by implementing
ISessionStore

 

Just a note, the current release will be the last to incorporate the
DataAccess component.  

The next release will be versionned 2.0 and will only focus on
DataMapper component.    

 

Custom store are rarely used and I try to keep the configuration file
minimal and used code for advanced configuration.

-- 
Cheers,
Gilles

<a href=" http://www.amazon.com/gp/registry/6JCP7AORB0LE
<http://www.amazon.com/gp/registry/6JCP7AORB0LE> ">Wish List</a> 


Re: Writing a custom session store by implementing ISessionStore

Posted by Gilles Bayon <ib...@gmail.com>.
Just a note, the current release will be the last to incorporate the
DataAccess component.
The next release will be versionned 2.0 and will only focus on DataMapper
component.

Custom store are rarely used and I try to keep the configuration file
minimal and used code for advanced configuration.

-- 
Cheers,
Gilles

<a href="http://www.amazon.com/gp/registry/6JCP7AORB0LE">Wish List</a>

RE: Writing a custom session store by implementing ISessionStore

Posted by Greg Jackman <Gr...@nycity.com>.
Hi Gilles, sorry about that last message, I think I've got it going now,
the problem was that I wasn't setting the new store immediately after
creating the manager.

 

Just a though on how this could be improved...

 

I am using several different DaoManagers (as I have a few different
database that I need to connect to) and I have to set the Hybrid store
on each one separately. It might be nice for this to be put in the
configuration rather than in code. It seems to be something that just
needs to be set up once and then forgotten about.

 

Thanks for your help on fixing my issues,

 

Cheers,

Greg

 

________________________________

From: Greg Jackman [mailto:Greg.Jackman@nycity.com] 
Sent: Friday, 9 February 2007 1:16 p.m.
To: user-cs@ibatis.apache.org
Subject: RE: Writing a custom session store by implementing
ISessionStore

 

Hi Gilles,

 

I've moved to the latest version of the data access and data mapper
libraries.

 

Using the new session store I have the following problem when I try to
use my DAO methods: "DaoManager could not invoke CloseConnection(). No
connection was started. Call OpenConnection() first."  Does this mean
that by using a new session store, I am now responsible for opening and
closing connections when using the mapper?

 

Thanks,

Greg

 

________________________________

From: Gilles Bayon [mailto:ibatis.net@gmail.com] 
Sent: Friday, 9 February 2007 8:25 a.m.
To: user-cs@ibatis.apache.org
Subject: Re: Writing a custom session store by implementing
ISessionStore

 

Yes

On 2/8/07, Greg Jackman <Gr...@nycity.com> wrote: 

Thanks for that Gilles, I'll give it a go. Do I need to upgrade to the
latest beta version to be able to set the session store? 

 

Cheers,

Greg

 

________________________________

From: Gilles Bayon [mailto: ibatis.net@gmail.com] 
Sent: Friday, 9 February 2007 7:58 a.m .
To: user-cs@ibatis.apache.org
Subject: Re: Writing a custom session store by implementing
ISessionStore

 

You can used the HybridWebThreadSessionStore 
ISqlMapper mapper = builder.Configure(...);

 

mapper.SessionStore = new HybridWebThreadSessionStore( sqlMapper.Id );

 

Set the custom session store once you have build the ISqlMapper and
before you use it.

 


-- 
Cheers,
Gilles

<a href=" http://www.amazon.com/gp/registry/6JCP7AORB0LE
<http://www.amazon.com/gp/registry/6JCP7AORB0LE> ">Wish List</a> 




-- 
Cheers,
Gilles

<a href=" http://www.amazon.com/gp/registry/6JCP7AORB0LE
<http://www.amazon.com/gp/registry/6JCP7AORB0LE> ">Wish List</a> 


RE: Writing a custom session store by implementing ISessionStore

Posted by Greg Jackman <Gr...@nycity.com>.
Hi Gilles,

 

I've moved to the latest version of the data access and data mapper
libraries.

 

Using the new session store I have the following problem when I try to
use my DAO methods: "DaoManager could not invoke CloseConnection(). No
connection was started. Call OpenConnection() first."  Does this mean
that by using a new session store, I am now responsible for opening and
closing connections when using the mapper?

 

Thanks,

Greg

 

________________________________

From: Gilles Bayon [mailto:ibatis.net@gmail.com] 
Sent: Friday, 9 February 2007 8:25 a.m.
To: user-cs@ibatis.apache.org
Subject: Re: Writing a custom session store by implementing
ISessionStore

 

Yes

On 2/8/07, Greg Jackman <Gr...@nycity.com> wrote: 

Thanks for that Gilles, I'll give it a go. Do I need to upgrade to the
latest beta version to be able to set the session store? 

 

Cheers,

Greg

 

________________________________

From: Gilles Bayon [mailto: ibatis.net@gmail.com] 
Sent: Friday, 9 February 2007 7:58 a.m .
To: user-cs@ibatis.apache.org
Subject: Re: Writing a custom session store by implementing
ISessionStore

 

You can used the HybridWebThreadSessionStore 
ISqlMapper mapper = builder.Configure(...);

 

mapper.SessionStore = new HybridWebThreadSessionStore( sqlMapper.Id );

 

Set the custom session store once you have build the ISqlMapper and
before you use it.

 


-- 
Cheers,
Gilles

<a href=" http://www.amazon.com/gp/registry/6JCP7AORB0LE
<http://www.amazon.com/gp/registry/6JCP7AORB0LE> ">Wish List</a> 




-- 
Cheers,
Gilles

<a href=" http://www.amazon.com/gp/registry/6JCP7AORB0LE
<http://www.amazon.com/gp/registry/6JCP7AORB0LE> ">Wish List</a> 


Re: Writing a custom session store by implementing ISessionStore

Posted by Gilles Bayon <ib...@gmail.com>.
Yes

On 2/8/07, Greg Jackman <Gr...@nycity.com> wrote:
>
>  Thanks for that Gilles, I'll give it a go. Do I need to upgrade to the
> latest beta version to be able to set the session store?
>
>
>
> Cheers,
>
> Greg
>
>
>  ------------------------------
>
> *From:* Gilles Bayon [mailto:ibatis.net@gmail.com]
> *Sent:* Friday, 9 February 2007 7:58 a.m.
> *To:* user-cs@ibatis.apache.org
> *Subject:* Re: Writing a custom session store by implementing
> ISessionStore
>
>
>
> You can used the HybridWebThreadSessionStore
> ISqlMapper mapper = builder.Configure(...);
>
>
>
> mapper.SessionStore = new HybridWebThreadSessionStore( sqlMapper.Id );
>
>
>
> Set the custom session store once you have build the ISqlMapper and before
> you use it.
>
>
>
>
> --
> Cheers,
> Gilles
>
> <a href="http://www.amazon.com/gp/registry/6JCP7AORB0LE">Wish List</a>
>



-- 
Cheers,
Gilles

<a href="http://www.amazon.com/gp/registry/6JCP7AORB0LE">Wish List</a>

RE: Writing a custom session store by implementing ISessionStore

Posted by Greg Jackman <Gr...@nycity.com>.
Thanks for that Gilles, I'll give it a go. Do I need to upgrade to the
latest beta version to be able to set the session store?

 

Cheers,

Greg

 

________________________________

From: Gilles Bayon [mailto:ibatis.net@gmail.com] 
Sent: Friday, 9 February 2007 7:58 a.m.
To: user-cs@ibatis.apache.org
Subject: Re: Writing a custom session store by implementing
ISessionStore

 

You can used the HybridWebThreadSessionStore
ISqlMapper mapper = builder.Configure(...);

 

mapper.SessionStore = new HybridWebThreadSessionStore( sqlMapper.Id );

 

Set the custom session store once you have build the ISqlMapper and
before you use it.

 


-- 
Cheers,
Gilles

<a href="http://www.amazon.com/gp/registry/6JCP7AORB0LE">Wish List</a> 


Re: Writing a custom session store by implementing ISessionStore

Posted by Gilles Bayon <ib...@gmail.com>.
You can used the HybridWebThreadSessionStore
ISqlMapper mapper = builder.Configure(...);

mapper.SessionStore = new HybridWebThreadSessionStore( sqlMapper.Id );

Set the custom session store once you have build the ISqlMapper and before
you use it.


-- 
Cheers,
Gilles

<a href="http://www.amazon.com/gp/registry/6JCP7AORB0LE">Wish List</a>

Re: Writing a custom session store by implementing ISessionStore

Posted by Gilles Bayon <ib...@gmail.com>.
You can find another implementation see
http://ibatis.apache.org/SDK/dotnet/IBatisNet.DataAccess.SessionStore.html


-- 
Cheers,
Gilles

<a href="http://www.amazon.com/gp/registry/6JCP7AORB0LE">Wish List</a>