You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Olof Næssén <ol...@gmail.com> on 2007/11/27 15:25:08 UTC

[T5] Persistent field strategy and Hibernate

I've stumbled on a problem with implementing a custom persistent field
strategy that uses Hibernate. As the the application uses Hibernate I
would like to use Hibernate entities as models, but this causes a
problem when storing entities in the session as our Hibernate session
is created per request and the HTTP session's stored values live
longer than a request. Somewhere the entities need to be merged so
they get re-attached to the new session.

Our solution has been to implement a custom persistent field strategy
that merges an entity before returning the persistent value from the
HTTP session. This approach worked just fine until we added two
different pages that stored the same entity in the HTTP session. At
some point the two different values are read from the HTTP session
causing one of them to be overwritten even though they reside in
different pages.

What I don't understand is when the persistent values are read, that
is when PersistentFieldStrategy.gatherFieldChanges is actually called.
It seems that values are sometimes read even though a page is visited
that lacks persistent fields or that
PersistentFieldStrategy.gatherFieldChanges is called for a different
page than the visited page.

Has this something to do with the implementation of the gathering of
persistent field information? Is perhaps the usage of a custom
persistent field strategy the wrong approach? At the moment I'm a bit
confused and would appreciate any help and or pin points I can get.

/Olof

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] Persistent field strategy and Hibernate

Posted by Ted Steen <te...@gmail.com>.
We still got this problem. Is there anyone who know anything about this?

If I read persistent fields from one page, why do persistent fields
(with the same type) from other pages get read from the session
aswell?
This is a problem when working with hibernate.

Thanks!
/Ted

2007/11/27, Olof Næssén <ol...@gmail.com>:
> I've stumbled on a problem with implementing a custom persistent field
> strategy that uses Hibernate. As the the application uses Hibernate I
> would like to use Hibernate entities as models, but this causes a
> problem when storing entities in the session as our Hibernate session
> is created per request and the HTTP session's stored values live
> longer than a request. Somewhere the entities need to be merged so
> they get re-attached to the new session.
>
> Our solution has been to implement a custom persistent field strategy
> that merges an entity before returning the persistent value from the
> HTTP session. This approach worked just fine until we added two
> different pages that stored the same entity in the HTTP session. At
> some point the two different values are read from the HTTP session
> causing one of them to be overwritten even though they reside in
> different pages.
>
> What I don't understand is when the persistent values are read, that
> is when PersistentFieldStrategy.gatherFieldChanges is actually called.
> It seems that values are sometimes read even though a page is visited
> that lacks persistent fields or that
> PersistentFieldStrategy.gatherFieldChanges is called for a different
> page than the visited page.
>
> Has this something to do with the implementation of the gathering of
> persistent field information? Is perhaps the usage of a custom
> persistent field strategy the wrong approach? At the moment I'm a bit
> confused and would appreciate any help and or pin points I can get.
>
> /Olof
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
/ted

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org