[hibernate-dev] Feature for handling getNextValue work in same transaction.
Sanne Grinovero
sanne at hibernate.org
Sun Aug 11 07:45:06 EDT 2013
On 9 August 2013 19:08, Jeremy Whiting <jwhiting at redhat.com> wrote:
> Hi Scott,
> To the database the sequence of statements will be as follows. The
> statements around the read and write of sequence table are an example to
> put the sequence_table work into context.
>
> tx1 BEGIN
> SELECT blah
> SELECT blah
> UPDATE blah
> SELECT * from sequence_table;
> UPDATE sequence_table SET ids=?;
> INSERT INTO blah
> UPDATE blah
> tx1 END
> tx1 COMMIT
>
> The work will not be isolated from the current transaction tx1.
> Concurrently running transactions will see the changes to sequence_table
> depending on the isolation level set when the pool is filled.
What is the use case for creating the sequence in the same transaction?
Sequences are usually needed to be absolutely independent from transactions.
That is generally the case for "real" sequence constructs:
- http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_6015.htm
With sequence tables we're providing alternative strategies but -as a
user- I would expect these to follow the same semantic, i.e. to be
fully independent from any running transaction.
Sanne
>
> Regards,
> Jeremy
>
> On 09/08/13 18:20, Scott Marlow wrote:
>> On 08/08/2013 11:21 AM, Jeremy Whiting wrote:
>>> Hi,
>>> I am looking for feedback on changes to provide the ability for work
>>> to be completed in a currently running transaction. For example when a
>>> TableGenerator or SequenceGenerator is being used for generating unique
>>> ids. The statements that select then update the db are executed in a
>>> separate transaction.
>>>
>>> There is a jira for this feature.
>>>
>>> https://hibernate.atlassian.net/browse/HHH-8429
>>>
>>> Attached to the jira is a diagram. See this link
>>> https://hibernate.atlassian.net/secure/attachment/19534/hibernate-class-structure-allowing-same-tx-support.png
>>>
>>>
>>> This diagram shows what I currently have implemented. It shows the
>>> existing classes and the new classes shaded in light blue. The methods
>>> on a new class IsolationAware show how I've re-jigged most the
>>> implementation from JtaTransaction to it's new ancestor IsolationAware.
>>> A new concrete implementation of IsolationDelegate will negotiate the
>>> work to be executed in the same running transaction.
>>> The structure splits up the factory/transaction/delegate classes into
>>> two groups. "same transaction" and "separate transaction". This has only
>>> been done for JtaTransaction and the same will probably be necessary for
>>> CMTTransaction as it also uses a separate transaction to complete work.
>>> That has been left out to keep the diagram simple.
>>
>> Your talking about making code changes here but I'm not following
>> exactly how this new features works. I added my questions about this
>> to the jira. When you respond there or here, could you please also
>> include how this new feature depends on isolation level (if it
>> requires a certain isolation level).
>>
>>>
>>> The option of using aggregation at the point where implementers of
>>> TransactionImplementor are instantiated has been considered. Before too
>>> much effort is expended coding I wondered what others thought is the
>>> preferred way to implement this feature.
>>>
>>> Jeremy
>>>
>>> _______________________________________________
>>> hibernate-dev mailing list
>>> hibernate-dev at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>>>
>>
>
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
More information about the hibernate-dev
mailing list