Oscar

Thanks a lot for your posts. I use your method BurrowFramework
().GetSessionByName(string PersitenceName);

But It does'nt work if the Session is directly called by Hibernate (i
think) and if the Entity is not a NHibernateProxy.

In fact, i have an exception in SessionImpl.cs in the method : public
object GetIdentifier(object obj)

(...)
if (obj is INHibernateProxy)
{
        ILazyInitializer li = ((INHibernateProxy)
obj).HibernateLazyInitializer;
        if (li.Session != this)
        {
                throw new TransientObjectException("The proxy was not associated
with this session");
        }
        return li.Identifier;
}
else
{
        EntityEntry entry = persistenceContext.GetEntry(obj); //HERE IS THE
PROBLEM : not the good persistenceContext ??
        if (entry == null) //entry is not find :(
        {
                throw new TransientObjectException("the instance was not 
associated
with this session");
        }
        return entry.Id;
}
(...)

I don't know how resolve this problem :(

JbM

On 26 déc 2008, 23:30, "Oscar Orduz Acosta" <[email protected]> wrote:
> You're welcome Manu,
>
> BTW: The JIRA ticked has been submited.
>
> Oscar
>
> 2008/12/24 Manu <[email protected]>
>
>
>
>
>
> > Oscar,
>
> > Sorry for the late reply. I had been very busy with some deadlines...
>
> > Thank you very much for your code. You have saved me a lot of time. It
> > is exactly what I need!
>
> > On 19 dic, 23:00, "Oscar Orduz Acosta" <[email protected]> wrote:
> > > Hello Manu:
>
> > > I had similar experience, what I needed were have the same entities but
> > in
> > > different databases (even in different Engines i.e Oracle, MsSQl, etc),
> > so
> > > we can support almost transparently several client implementations in
> > > Database but with the same design.
>
> > > I have to custom the code of Burrow in the following files:
>
> > > BurrowFramework.cs:
> > >         /// <summary>
> > >         /// Numero método incluido para Framework
> > >         /// </summary>
> > >         /// <param name="configurationId"></param>
> > >         /// <returns></returns>
> > >         public ISessionFactory GetSessionFactoryByName(string
> > > configurationId)
> > >         {
> > >             if (PersistenceUnitRepo.Instance == null)
>
> > >  PersistenceUnitRepo.Initialize(BurrowEnvironment.Configuration);
> > >             return
> > > PersistenceUnitRepo.Instance.GetPUByName(configurationId).SessionFactory;
> > >         }
> > >         /// <summary>
> > >         /// Oscar Orduz.
> > >         /// </summary>
> > >         /// <param name="configurationId"></param>
> > >         /// <returns></returns>
> > >         public ISession GetSessionByName(string configurationId)
> > >         {
> > >             AbstractConversation c =
> > > ((AbstractConversation)CurrentConversation);
> > >             return c.GetSessionByName(configurationId);
> > >         }
>
> > > AbstractConversation.cs
>
> > >        /// <summary>
> > >         /// Oscar Orduz
> > >         /// </summary>
> > >         /// <param name="configurationId"></param>
> > >         /// <returns></returns>
> > >         public ISession GetSessionByName(string configurationId)
> > >         {
> > >             SessionManager sm = string.IsNullOrEmpty(configurationId) ?
> > > GetSessionManager() : GetSessionManagerByName(configurationId);
> > >             return GetSession(sm);
> > >         }
> > >         /// <summary>
> > >         /// Método creado para el manejo de la sesión para el framework
> > de
> > > PS
> > >         /// </summary>
> > >         /// <param name="configurationId"></param>
> > >         /// <returns></returns>
> > >         internal SessionManager GetSessionManagerByName(string
> > > configurationId)
> > >         {
> > >             return
> > > sessManagers[PersistenceUnitRepo.Instance.GetPUByName(configurationId)];
> > >         }
>
> > > PersistenceUnitRepo.cs
> > >         /// <summary>
> > >         /// Método creado para la recuperación por nombre
> > >         /// </summary>
> > >         /// <param name="configurationId"></param>
> > >         /// <returns></returns>
> > >         public PersistenceUnit GetPUByName(string configurationId)
> > >         {
> > >             if (PersistenceUnits.Count == 1)
> > >             {
> > >                 return PersistenceUnits[0];
> > >             }
> > >             foreach (PersistenceUnit pu in persistenceUnits)
> > >             {
> > >                 if (pu.Name == configurationId)
> > >                 {
> > >                     return pu;
> > >                 }
> > >             }
>
> > >             throw new GeneralException("Persistence Unit cannot be found
> > for
> > > " + configurationId);
> > >         }
>
> > > I have mantained this code for three releases of burrow and until now it
> > > works fine
>
> > > Hope this help.
>
> > > Oscar
>
> > > 2008/12/18 Manu <[email protected]>
>
> > > > I have been looking at the Burrow source code and I'm not sure if I
> > > > can use its GenericDAO to handle multiple databases the way I want.
>
> > > > I have see that the Session property of the GenericDAO class calls
> > > > BurrowFramework().GetSession(_NHEntityType) and that works good if the
> > > > multiples databases you're working with have different entities.
> > > > However, it can't handle multiple databases with the same mapped
> > > > entities as the GetSession method always returns the first
> > > > PersistenceUnit. So I think GenericDAO needs an overload to specify a
> > > > session factory name to retrieve the proper PersistenceUnit by name
> > > > instead of by type.
>
> > > > As I have started today to look at Burrow I may be wrong, so if anyone
> > > > is familiar with it I'd appreciate if he can show some light about
> > > > that problem.- Ocultar texto de la cita -
>
> > > - Mostrar texto de la cita -- Masquer le texte des messages précédents -
>
> - Afficher le texte des messages précédents -

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to