You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Angelo Chen <an...@yahoo.com.hk> on 2008/04/06 11:04:29 UTC

T5: multiple sessions with Tapestry-Hibernate?

Hi,

I have a need to generate a sequential ID for employee entity, the entity
has its own primary key which is auto incremented. I use a one-record table
that has a field 'next_id', every time when a new employee is added, I'll
just get that record and increment the field, this works most of the time,
but if there are multiple workstations adding new employees, problem will
happen, it will have this 'dead lock' issue. I'm thinking of
accessing/incrementing the one-record table to be in a separate Hibernate
session, it will immediately flush after incrementing the 'next_id', this
will leave a very small window for that record to be locked and allowing
other workstations to continue, and question is, does Tapestry-Hibernate
allow multiple Hibernate sessions? if not, any solution to this? Thanks.

Angelo
-- 
View this message in context: http://www.nabble.com/T5%3A-multiple-sessions-with-Tapestry-Hibernate--tp16522245p16522245.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5: multiple sessions with Tapestry-Hibernate?

Posted by Josh Canfield <jo...@gmail.com>.
> does Tapestry-Hibernate
> allow multiple Hibernate sessions? if not, any solution to this?  
> Thanks.

Yes, you can grab the HibernateSessionSource and call create to get a  
second session.

You are responsible for this session, so make sure you close it.

Josh



On Apr 6, 2008, at 2:04 AM, Angelo Chen wrote:

>
> Hi,
>
> I have a need to generate a sequential ID for employee entity, the  
> entity
> has its own primary key which is auto incremented. I use a one- 
> record table
> that has a field 'next_id', every time when a new employee is added,  
> I'll
> just get that record and increment the field, this works most of the  
> time,
> but if there are multiple workstations adding new employees, problem  
> will
> happen, it will have this 'dead lock' issue. I'm thinking of
> accessing/incrementing the one-record table to be in a separate  
> Hibernate
> session, it will immediately flush after incrementing the 'next_id',  
> this
> will leave a very small window for that record to be locked and  
> allowing
> other workstations to continue, and question is, does Tapestry- 
> Hibernate
> allow multiple Hibernate sessions? if not, any solution to this?  
> Thanks.
>
> Angelo
> -- 
> View this message in context: http://www.nabble.com/T5%3A-multiple-sessions-with-Tapestry-Hibernate--tp16522245p16522245.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


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