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 Shawn Hinsey <Sh...@miva.com> on 2006/04/27 19:50:26 UTC
async access to DaoManager
Hello,
I have the following base class that all of my domain objects use to
grab references to the appropriate DAO.
A couple of common usages:
BookCollection myBooks = Book.Load();
Book myBook = new Book();
myBook.Title = "A Tale of Two Cities";
myBook.Save();
public class DomainBase
{
static DomainBase()
{
_builder = new DomDaoManagerBuilder();
_builder.Configure();
_manager = DaoManager.GetInstance("SqlMapDao");
}
protected static DaoManager _manager;
protected static DomDaoManagerBuilder _builder;
public static T GetDao<T>()
{
try
{
return (T)_manager.GetDao(typeof(T));
}
catch (Exception ex)
{
throw ex;
}
}
}
The problem I'm running into is that when I invoke GetDao from an
AsyncCallback delegate, I run into this exception:
IBatisNet.DataAccess.Exceptions.DataAccessException: There is already a
DAO Context with the ID 'SqlMapDao'.
What am I missing in order to make this thread-safe?
Re: async access to DaoManager
Posted by Gilles Bayon <ib...@gmail.com>.
Which version do you use ? in which context web, window ?
On 4/27/06, Shawn Hinsey <Sh...@miva.com> wrote:
>
> Hello,
>
> I have the following base class that all of my domain objects use to
> grab references to the appropriate DAO.
>
> A couple of common usages:
>
> BookCollection myBooks = Book.Load();
>
> Book myBook = new Book();
> myBook.Title = "A Tale of Two Cities";
> myBook.Save();
>
> public class DomainBase
> {
> static DomainBase()
> {
> _builder = new DomDaoManagerBuilder();
> _builder.Configure();
> _manager = DaoManager.GetInstance("SqlMapDao");
> }
>
> protected static DaoManager _manager;
>
> protected static DomDaoManagerBuilder _builder;
>
> public static T GetDao<T>()
> {
> try
> {
> return (T)_manager.GetDao(typeof(T));
> }
> catch (Exception ex)
> {
> throw ex;
> }
> }
> }
>
> The problem I'm running into is that when I invoke GetDao from an
> AsyncCallback delegate, I run into this exception:
>
> IBatisNet.DataAccess.Exceptions.DataAccessException: There is already a
> DAO Context with the ID 'SqlMapDao'.
>
> What am I missing in order to make this thread-safe?
>
>