Well, if you just store the Person object, you have to reattach it to the
current session (which is what my code does).

I don't want to store just the id in the session.  You need to store the
whole object to keep the version information (unless of course you don't
need the optimistic locking stuff).  You're not supposed to manually set the
version property on Hibernate-managed entities.  Hibernate will do that.  

I don't use the classes in hivetranse or honeycomb.  I have my own classes
for dealing with all of this and they work for me.  You're welcome to use
it.  It's all Apache v2.0 licensed.  You can do all the transaction
demarcation stuff and everything using the Spring syntax.  The example
application (tapernate-example) shows how it all works.  I'm going to be
adding my stuff to the honeycomb project once we figure out where it's going
to live (javaforge vs. sourceforge).

-----Original Message-----
From: Andreas Bulling [mailto:[EMAIL PROTECTED] On Behalf Of
Andreas Bulling
Sent: Saturday, April 22, 2006 10:49 AM
To: Tapestry users
Subject: Re: tapestry/hibernate sessions & pageBeginRender()

On 22. Apr 2006 - 09:17:49, James Carman wrote:
| 1.  Well, here's what would happen.  Suppose I want to update a Person
| object on my EditPerson page.  I use the "session" persistence strategy
and
| I just store the id of the person.  So, I render the EditPage and it shows
a
| form.  I edit some values and I submit my request.  Suppose someone beat
me
| to the punch, though.  While I was sitting there looking at the data from
| this Person object and contemplating what their real first name should be,
| someone else used the edit page to update the exact same Person object.
| When my request comes in, I'll do a Hibernate query to lookup the Person
| object (by id) in the database.  I'll set some properties on it and commit
| my changes.  Since I got the current values out of the database by
querying
| for the object, my request will work just fine and I will have overwritten
| the changes the other user has done.  If I use the "entity" persistence
| strategy (my implementation), I will be updating an object that has the
old
| version number in it.  Hibernate will throw an exception and I will not be
| allowed to overwrite the changes the other user has done.

Does this problem still exist if I use the "session" strategy
but persist the whole Person object?

If I understood you correctly this means that your implementation is
currently not complete as the part which saves only the id in the
session is missing, right?! Or did you mean with your third sentence
that you do something like this

@Persist
public abstract Integer getPersonId();
public abstract void setPersonId(Integer personId);

Cheers,
  Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to