Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
JSP - A mailing list about Java Server Pages specification and reference
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Subject: Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Subject: Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
how to avoid transaction aborting

how to avoid transaction aborting

2006-02-08       - By bin cai

 Back
Reply:     1     2     3  

Thank you very much, Mike. I will do more research on this issue.
 bin

Mike New <mike@(protected)> wrote:
 > Hi, Dear guys
> I really hope you can help me to solve this problem.
> for example:
> i open two transactions which both get access to same record in
> database. so two objects are loaded for this record. and in these two
> transactions, both of these object(mapped to same record) are modified.
> upon committing, one these two transactions will be aborted (dirty
> modification). and user lost all the data. I think it is not acceptable
> for user. and these problems happen quite often since the many
> transactions in our system are long transactions which last over ten
> minutes or longer.
>
> Could anyone can give me some hint? i search internet and did not get
> some userful info related to that?
> I don't know if it is practicle to implemented dirty checking before
> committing anything to database in transaction?

A database transaction should take milliseconds, not minutes. If you need
long running transactions you will have to create some kind of temporary
object which is then "committed" (i.e. overwrites the current object).

As for two users modifying the same data, I think you have to decide
exactly what behaviour you want and program it yourself. Long-running
database transactions are not the answer, because that's not what database
or J2EE transactions are meant for. Also, I don't think you can have two
transactions open on the same data. I can't imagine what that means.


So you could do something like this:

User A makes a change to some data:
The data field is copied, a "LongTransaction" object is created, a
normal transaction is started, the change is made, and the
transaction is committed. The temporary data is stored but the
original data is intact.

User B makes a change to the same data:
The system gets a reference to the LongTransaction, noting it is in
progress. This gets the temporary copy of the data, makes its
change and commits it.

User A makes another change:
Same thing again. All these changes are made on the copy until
there is an explicit "commit" called on the LongTransaction.

Finally, case 1 or case 2:

Case 1: User X rolls back the transaction.
The LongTransaction is told to roll back. It removes the temporary
object from memory and from the database. The original object is
still intact.

Case 2: User X commits the LongTransaction:
The temporary data copy replaces the original copy. The
LongTransaction is finished/destroyed/cleaned up.


The above is simplistic, but I hope you get the idea.

Mike
-- ---- ---- ------ _/ /// // -- ---- ---- ---- --

===========================================================================
To unsubscribe, send email to listserv@(protected) and include in the body
of the message "signoff J2EE-INTEREST". For general help, send email to
listserv@(protected) and include in the body of the message "help".



-- ---- ---- ---- ---- ---- -----
Brings words and photos together (easily) with
PhotoMail  - it's free and works with Yahoo! Mail.

===========================================================================
To unsubscribe, send email to listserv@(protected) and include in the body
of the message "signoff J2EE-INTEREST".  For general help, send email to
listserv@(protected) and include in the body of the message "help".

<div>Thank you very much, Mike. I will do more research on this issue. </div>  
<div>bin<BR><BR><B><I>Mike New &lt;mike@(protected)&gt;</I></B> wrote:</div>  
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT
: #1010ff 2px solid">&gt; Hi, Dear guys<BR>&gt; I really hope you can help me to
solve this problem.<BR>&gt; for example:<BR>&gt; i open two transactions which
both get access to same record in<BR>&gt; database. so two objects are loaded
for this record. and in these two<BR>&gt; transactions, both of these object
(mapped to same record) are modified.<BR>&gt; upon committing, one these two
transactions will be aborted (dirty<BR>&gt; modification). and user lost all
the data. I think it is not acceptable<BR>&gt; for user. and these problems
happen quite often since the many<BR>&gt; transactions in our system are long
transactions which last over ten<BR>&gt; minutes or longer.<BR>&gt;<BR>&gt;
Could anyone can give me some hint? i search internet an
d did
not get<BR>&gt; some userful info related to that?<BR>&gt; I don't know if it
is practicle to implemented dirty checking before<BR>&gt; committing anything
to database in transaction?<BR><BR>A database transaction should take
milliseconds, not minutes. If you need<BR>long running transactions you will
have to create some kind of temporary<BR>object which is then "committed" (i.e.
overwrites the current object).<BR><BR>As for two users modifying the same data
, I think you have to decide<BR>exactly what behaviour you want and program it
yourself. Long-running<BR>database transactions are not the answer, because
that's not what database<BR>or J2EE transactions are meant for. Also, I don't
think you can have two<BR>transactions open on the same data. I can't imagine
what that means.<BR><BR><BR>So you could do something like this:<BR><BR>User A
makes a change to some data:<BR>The data field is copied, a "LongTransaction"
object is created, a<BR>normal transaction is started, the
change
is made, and the<BR>transaction is committed. The temporary data is stored but
the<BR>original data is intact.<BR><BR>User B makes a change to the same data:
<BR>The system gets a reference to the LongTransaction, noting it is in<BR
>progress. This gets the temporary copy of the data, makes its<BR>change and
commits it.<BR><BR>User A makes another change:<BR>Same thing again. All these
changes are made on the copy until<BR>there is an explicit "commit" called on
the LongTransaction.<BR><BR>Finally, case 1 or case 2:<BR><BR>Case 1: User X
rolls back the transaction.<BR>The LongTransaction is told to roll back. It
removes the temporary<BR>object from memory and from the database. The original
object is<BR>still intact.<BR><BR>Case 2: User X commits the LongTransaction:
<BR>The temporary data copy replaces the original copy. The<BR>LongTransaction
is finished/destroyed/cleaned up.<BR><BR><BR>The above is simplistic, but I
hope you get the idea.<BR><BR>Mike<BR>-- ---- ---- ------ _
/ /// //
-- ---- ---- ---- --<BR><BR>==================================================
=========================<BR>To unsubscribe, send email to listserv@(protected)
and include in the body<BR>of the message "signoff J2EE-INTEREST". For general
help, send email to<BR>listserv@(protected) and include in the body of the
message "help".<BR></BLOCKQUOTE><BR><p>
               <hr size=1>Brings words and photos together (easily) with<br>
<a href="http://us.rd.yahoo.com/mail_us/taglines/PMDEF3/*http://photomail.mail
.yahoo.com">PhotoMail </a> - it's free and works with Yahoo! Mail.
===========================================================================
To unsubscribe, send email to listserv@(protected) and include in the body
of the message "signoff J2EE-INTEREST".  For general help, send email to
listserv@(protected) and include in the body of the message "help".
<p>

©2008 junlu.com - Jax Systems, LLC, U.S.A.