Version 5

    &12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531; (Transactions)

     

    &12399;&12376;&12417;&12395; (Introduction)

    Transaction support is a key feature in any enterprise middleware. It guarantees the integrity of the system even in case of random network or hardware failures. Transactions are especially important in database applications. The application's business logic often requires that consecutive database updates to be all successful, or there should be no updates at all and we should re-start the updates again. EJB 3.0 makes it very easy to declare transaction properties for any method in any POJO class using annotations. In fact, transactions tie together EJB 3.0 entity beans and session beans. In this trail, you will learn how to use transaction annotations.

     

    &12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12469;&12509;&12540;&12488;&12399;&12289;&12393;&12398;&12456;&12531;&12479;&12540;&12503;&12521;&12452;&12474;&12511;&12489;&12523;&12454;&12455;&12450;&12391;&12418;&37749;&12392;&12394;&12427;&27231;&33021;&12391;&12377;&12290;&12381;&12428;&12399;&19981;&30906;&23450; (&35379;&27880;&65306;&19981;&23433;&23450;&65311;)&12394;&12493;&12483;&12488;&12527;&12540;&12463;&12420;&12495;&12540;&12489;&12454;&12455;&12450;&38556;&23475;&12395;&12362;&12356;&12390;&12373;&12360;&12289;&12471;&12473;&12486;&12512;&12398;&20445;&20840;&24615;&12434;&20445;&35388;&12375;&12414;&12377;&12290;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12399;&12487;&12540;&12479;&12505;&12540;&12473;&12450;&12503;&12522;&12465;&12540;&12471;&12519;&12531;&12391;&29305;&12395;&37325;&35201;&12391;&12377;&12290;&12450;&12503;&12522;&12465;&12540;&12471;&12519;&12531;&12398;&12499;&12472;&12493;&12473;&12525;&12472;&12483;&12463;&12391;&12399;&12289;&36899;&32154;&12375;&12383;&12487;&12540;&12479;&12505;&12540;&12473;&12398;&26356;&26032;&12399;&12377;&12409;&12390;&25104;&21151;&12377;&12427;&12363;&12289;&12373;&12418;&12394;&12367;&12400;&12414;&12387;&12383;&12367;&26356;&26032;&12364;&36215;&12371;&12425;&12378;&20877;&24230;&26356;&26032;&12434;&12420;&12426;&30452;&12377;&12371;&12392;&12395;&12394;&12427;&12289;&12392;&12356;&12358;&12371;&12392;&12364;&12424;&12367;&27714;&12417;&12425;&12428;&12414;&12377;&12290;EJB 3.0&12391;&12399;&12450;&12494;&12486;&12540;&12471;&12519;&12531;&12434;&20351;&12358;&12371;&12392;&12391;&12289;&12393;&12398;POJO&12463;&12521;&12473;&12398;&12393;&12398;&12513;&12477;&12483;&12489;&12395;&12418;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12503;&12525;&12497;&12486;&12451;&12434;&38750;&24120;&12395;&31777;&21336;&12395;&23459;&35328;&12391;&12365;&12414;&12377;&12290;&20107;&23455;&19978;&12289;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12399;EJB 3.0&12398;&12456;&12531;&12486;&12451;&12486;&12451;Bean&12392;&12475;&12483;&12471;&12519;&12531;Bean&12434;&32080;&12403;&20184;&12369;&12414;&12377;&12290;&12371;&12398;&23567;&36947;&12391;&12399;&12289;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12450;&12494;&12486;&12540;&12471;&12519;&12531;&12398;&20351;&12356;&26041;&12434;&23398;&12435;&12391;&12356;&12365;&12414;&12377;&12290;

     

    &12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12450;&12494;&12486;&12540;&12471;&12519;&12531; (Transaction annotations)

    In EJB 3.0 applications, transaction properties are most frequently declared for methods in session beans. If a method requires transaction, all operations in the method, including database updates, are only committed after the method exits normally. If an uncaught application exception is thrown in this method (or in the methods it calls), the transaction manager rolls back all the changes (i.e., database updates). The transaction declaration annotation is @TransactionAttribute. It can take the following arguments.

     

    EJB 3.0&12450;&12503;&12522;&12465;&12540;&12471;&12519;&12531;&12391;&12399;&12289;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12503;&12525;&12497;&12486;&12451;&12399;&12475;&12483;&12471;&12519;&12531;Bean&12398;&12513;&12477;&12483;&12489;&12395;&23550;&12375;&12390;&26368;&12418;&38971;&32321;&12395;&23459;&35328;&12373;&12428;&12414;&12377;&12290;&12354;&12427;&12513;&12477;&12483;&12489;&12364;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12434;&35201;&27714;&12377;&12427;&22580;&21512;&12289;&12381;&12398;&12513;&12477;&12483;&12489;&12391;&12398;&12487;&12540;&12479;&12505;&12540;&12473;&12398;&26356;&26032;&12434;&21547;&12416;&12377;&12409;&12390;&12398;&25805;&20316;&12399;&12289;&12513;&12477;&12483;&12489;&12364;&27491;&24120;&12395;&32066;&20102;&12375;&12383;&24460;&12395;&12398;&12415;&12467;&12511;&12483;&12488;&12373;&12428;&12414;&12377;&12290;&12418;&12375;&12371;&12398;&12513;&12477;&12483;&12489;&20869;&12391;&65288;&12354;&12427;&12356;&12399;&12371;&12398;&12513;&12477;&12483;&12489;&12364;&21628;&12406;&12513;&12477;&12483;&12489;&20869;&12391;&65289;&12461;&12515;&12483;&12481;&12373;&12428;&12394;&12356;&12450;&12503;&12522;&12465;&12540;&12471;&12519;&12531;&20363;&22806;&12364;&25237;&12370;&12425;&12428;&12427;&12394;&12425;&12400;&12289;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12510;&12493;&12540;&12472;&12515;&12399;&12377;&12409;&12390;&12398;&22793;&26356;&65288;&12377;&12394;&12431;&12385;&12487;&12540;&12479;&12505;&12540;&12473;&12398;&26356;&26032;&65289;&12434;&12525;&12540;&12523;&12496;&12483;&12463;&12375;&12414;&12377;&12290;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12434;&23459;&35328;&12377;&12427;&12450;&12494;&12486;&12540;&12471;&12519;&12531;&12399;@TransactionAttribute&12391;&12377;&12290;&12371;&12428;&12399;&27425;&12398;&24341;&25968;&12434;&21462;&12427;&12371;&12392;&12364;&12391;&12365;&12414;&12377;&12290;

     

    • REQUIRED: The annotated method is executed within a transaction. If the caller method is already inside a transaction, the transaction is used; if not, a new transaction is generated.

     

    &12450;&12494;&12486;&12540;&12488;&12373;&12428;&12383;&12513;&12477;&12483;&12489;&12399;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12398;&20869;&37096;&12391;&23455;&34892;&12373;&12428;&12414;&12377;&12290;&21628;&12403;&20986;&12375;&20596;&12398;&12513;&12477;&12483;&12489;&12364;&26082;&12395;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&20869;&12395;&12356;&12427;&22580;&21512;&12399;&12289;&12381;&12398;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12364;&20351;&12431;&12428;&12414;&12377;&12290;&12381;&12358;&12391;&12394;&12369;&12428;&12400;&12289;&26032;&12375;&12356;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12364;&29983;&25104;&12373;&12428;&12414;&12377;&12290;

     

    • MANDATORY: The annotated method must be invoked inside a transaction (i.e., the caller must have a transaction already). Otherwise, an error is thrown.

     

    &12450;&12494;&12486;&12540;&12488;&12373;&12428;&12383;&12513;&12477;&12483;&12489;&12399;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12398;&20869;&37096;&12391;&21628;&12403;&20986;&12373;&12428;&12394;&12369;&12428;&12400;&12394;&12426;&12414;&12379;&12435;&65288;&12377;&12394;&12431;&12385;&21628;&12403;&20986;&12375;&20596;&12399;&26082;&12395;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12434;&25345;&12387;&12390;&12356;&12394;&12369;&12428;&12400;&12394;&12426;&12414;&12379;&12435;&65289;&12290;&12381;&12358;&12391;&12394;&12369;&12428;&12400;&12289;&12456;&12521;&12540;&12364;&25237;&12370;&12425;&12428;&12414;&12377;&12290;

     

    • REQUIRESNEW: The annotated method is executed within a newly generated transaction. If the caller method is already in a transaction, it is suspended.

     

    &12450;&12494;&12486;&12540;&12488;&12373;&12428;&12383;&12513;&12477;&12483;&12489;&12399;&26032;&12383;&12395;&29983;&25104;&12373;&12428;&12383;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12398;&20869;&37096;&12391;&23455;&34892;&12373;&12428;&12414;&12377;&12290;&21628;&12403;&20986;&12375;&20596;&12398;&12513;&12477;&12483;&12489;&12364;&26082;&12395;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&20869;&12395;&12356;&12427;&22580;&21512;&12289;&12381;&12398;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12399;&20013;&26029;&12373;&12428;&12414;&12377;&12290;

     

    • SUPPORTS: If the annotated method is called within a transaction, the transaction is used. If it is called without a transaction, no transaction will be created.

     

    &12450;&12494;&12486;&12540;&12488;&12373;&12428;&12383;&12513;&12477;&12483;&12489;&12364;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&20869;&12363;&12425;&21628;&12403;&20986;&12373;&12428;&12383;&22580;&21512;&12289;&12381;&12398;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12364;&20351;&12431;&12428;&12414;&12377;&12290;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12394;&12375;&12395;&21628;&12403;&20986;&12373;&12428;&12383;&22580;&21512;&12289;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12399;&29983;&25104;&12373;&12428;&12414;&12379;&12435;&12290;

     

    • NOT_SUPPORTED: If the annotated method is called within a transaction, an error will be thrown.

     

    &12450;&12494;&12486;&12540;&12488;&12373;&12428;&12383;&12513;&12477;&12483;&12489;&12364;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&20869;&12363;&12425;&21628;&12403;&20986;&12373;&12428;&12383;&22580;&21512;&12289;&12456;&12521;&12540;&12364;&25237;&12370;&12425;&12428;&12414;&12377;&12290;

     

    If a method does not have a transaction annotation, it is assigned the default transaction property REQUIRED by the EJB 3.0 container.

     

    &12513;&12477;&12483;&12489;&12364;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12450;&12494;&12486;&12540;&12471;&12519;&12531;&12434;&25345;&12383;&12394;&12356;&22580;&21512;&12289;&12487;&12501;&12457;&12523;&12488;&12398;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12503;&12525;&12497;&12486;&12451;&12391;&12354;&12427;REQUIRED&12364;EJB 3.0&12467;&12531;&12486;&12490;&12395;&12424;&12387;&12390;&21106;&12426;&24403;&12390;&12425;&12428;&12414;&12377;&12290;

     

    In EJB 3.0, the EntityManager must run in a transactional context to ensure the database integrity. The transaction manager always synchronizes the database when it commits (recall that, by default, the database is synchronized at the end of the current thread), or before the next database query, whichever comes first. You can call EntityManager.flush() to flush the in-memory updates to the database in the middle of a transaction.

     

    EJB 3.0&12391;&12399;&12289;EntityManager&12399;&12487;&12540;&12479;&12505;&12540;&12473;&12398;&20445;&20840;&24615;&12434;&30906;&20445;&12377;&12427;&12383;&12417;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12467;&12531;&12486;&12461;&12473;&12488;&20869;&12391;&21205;&20316;&12375;&12394;&12369;&12428;&12400;&12394;&12426;&12414;&12379;&12435;&12290;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12510;&12493;&12540;&12472;&12515;&12399;&12289;&12487;&12540;&12479;&12505;&12540;&12473;&12364;&12467;&12511;&12483;&12488;&12377;&12427;&12392;&12365;&65288;&12487;&12501;&12457;&12523;&12488;&12391;&12399;&12289;&12487;&12540;&12479;&12505;&12540;&12473;&12399;&12459;&12524;&12531;&12488;&12473;&12524;&12483;&12489;&12398;&26368;&24460;&12395;&21516;&26399;&21270;&12373;&12428;&12427;&12371;&12392;&12434;&24605;&12356;&20986;&12375;&12390;&12367;&12384;&12373;&12356;&65289;&12363;&27425;&12398;&12487;&12540;&12479;&12505;&12540;&12473;&12463;&12456;&12522;&12398;&21069;&12289;&12356;&12378;&12428;&12363;&26089;&12356;&12411;&12358;&12398;&12479;&12452;&12511;&12531;&12464;&12391;&24517;&12378;&12487;&12540;&12479;&12505;&12540;&12473;&12434;&21516;&26399;&21270;&12375;&12414;&12377;&65288;&35379;&27880;&65306;&12300;&12356;&12378;&12428;&12363;&26089;&12356;&12411;&12358;&12301;&12387;&12390;&12356;&12425;&12394;&12356;&65311;&65289;&12290;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12398;&36884;&20013;&12395;&12452;&12531;&12513;&12514;&12522;&12398;&26356;&26032;&12434;&12487;&12540;&12479;&12505;&12540;&12473;&12408;&12501;&12521;&12483;&12471;&12517;&12377;&12427;&12383;&12417;&12289;EntityManager.flush()&12434;&21628;&12406;&12371;&12392;&12364;&12391;&12365;&12414;&12377;&12290;

     

    &12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12525;&12540;&12523;&12496;&12483;&12463; (Transaction rollback)

    A transaction fails when the application throws a RuntimeException, which is typically database related, or an ApplicationException. Here is an example to define your own ApplicationException. You can throw it anywhere in the transaction to cause it fail -- even in the absence of a real database error.

     

    &12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12399;&12450;&12503;&12522;&12465;&12540;&12471;&12519;&12531;&12364;RuntimeException&12420;ApplicationException&12434;&25237;&12370;&12383;&12392;&12365;&12395;&22833;&25943;&12375;&12414;&12377;&12290;RuntimeException&12399;&12289;&36890;&24120;&12399;&12487;&12540;&12479;&12505;&12540;&12473;&12395;&38306;&12377;&12427;&12418;&12398;&12391;&12377;&12290;&27425;&12399;&29420;&33258;&12398;ApplicationException&12434;&23450;&32681;&12377;&12427;&20363;&12391;&12377;&12290;&12371;&12398;ApplicationException&12434;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&20869;&12398;&12393;&12371;&12391;&25237;&12370;&12390;&12418;&12289;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12434;&22833;&25943;&12373;&12379;&12427;&12371;&12392;&12364;&12391;&12365;&12414;&12377;--&12383;&12392;&12360;&29694;&23455;&12395;&12487;&12540;&12479;&12505;&12540;&12473;&12364;&12456;&12521;&12540;&12434;&36215;&12371;&12375;&12390;&12356;&12394;&12367;&12390;&12418;&12290;

     

     @ApplicationException(rollback=true)
     public class TransException extends Exception {
     
       public TransException () { }
     
     }
    

     

    When a transaction fails, the database is rolled back to its pre-transaction state, even if the persistence context has been flushed before in the transaction. All managed entity bean objects are detached. If you want to reuse those entity beans from a failed transaction, you have to manually set their IDs to 0.

     

    &12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12364;&22833;&25943;&12375;&12383;&12392;&12365;&12395;&12399;&12289;&12383;&12392;&12360;&27704;&32154;&24615;&12467;&12531;&12486;&12461;&12473;&12488;&12364;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&20013;&12395;&12501;&12521;&12483;&12471;&12517;&12373;&12428;&12390;&12356;&12390;&12418;&12289;&12487;&12540;&12479;&12505;&12540;&12473;&12399;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&21069;&12398;&29366;&24907;&12395;&12525;&12540;&12523;&12496;&12483;&12463;&12373;&12428;&12414;&12377;&12290;&12377;&12409;&12390;&12398;&31649;&29702;&23550;&35937;&12456;&12531;&12486;&12451;&12486;&12451;Bean&12458;&12502;&12472;&12455;&12463;&12488;&12399;&65288;&35379;&27880;&65306;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12363;&12425;&65289;&20999;&12426;&38626;&12373;&12428;&12414;&12377;&12290;&22833;&25943;&12375;&12383;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12363;&12425;&12371;&12428;&12425;&12398;&12456;&12531;&12486;&12451;&12486;&12451;Bean&12434;&20877;&21033;&29992;&12375;&12383;&12356;&22580;&21512;&12289;&12371;&12428;&12425;&12398;ID&12434;&25163;&21205;&12391;0&12395;&35373;&23450;&12375;&12394;&12369;&12428;&12400;&12394;&12426;&12414;&12379;&12435;&12290;

     

     

    &12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12398;&20351;&29992;&20363; (A transactional method example)

    In the following example, we generate random application exceptions inside the entity bean update loop in the updateExchangeRate() method. Since the method is declared transactional, the exception would cause all the updates to fail.

     

    &27425;&12398;&20363;&12391;&12399;&12289;updateExchangeRate() &12513;&12477;&12483;&12489;&12391;&12398;&12456;&12531;&12486;&12451;&12486;&12451;Bean&26356;&26032;&12523;&12540;&12503;&20869;&12391;&12521;&12531;&12480;&12512;&12395;&12450;&12503;&12522;&12465;&12540;&12471;&12519;&12531;&20363;&22806;&12434;&29983;&25104;&12375;&12390;&12356;&12414;&12377;&12290;&12371;&12398;&12513;&12477;&12483;&12489;&12399;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12434;&23459;&35328;&12373;&12428;&12390;&12356;&12427;&12398;&12391;&12289;&12371;&12398;&20363;&22806;&12395;&12424;&12426;&12377;&12409;&12390;&12398;&26356;&26032;&12399;&22833;&25943;&12375;&12414;&12377;&12290;

     

     @Stateless
     public class TransCalculator implements Calculator {
     
       @PersistenceContext
       protected EntityManager em;
     
     
       // ... ...
     
       @TransactionAttribute(TransactionAttributeType.REQUIRED)
       public void updateExchangeRate (double newrate) throws Exception {
         Collection <TimedRecord> rc = 
           em.createQuery("from TimedRecord r").getResultList();
         int size = rc.size ();
         
         for (Iterator iter = rc.iterator(); iter.hasNext();) {
           TimedRecord r = (TimedRecord) iter.next();
           r.setSaving(r.getSaving() * newrate);
           r.setResult(r.getResult() * newrate);
     
           // Emulate a failure
           
           // Calculate failure probability for each loop
           // in order for the overall failure probability
           // to be 50%
           double prob = Math.pow (0.5, 1./size);
           if (Math.random() > prob) {
             // Emulated failure causes rollback
             throw new TransException ();
             
             // Or throw a RuntimeException to trigger rollback
           }
         }
       }
    

     

    Click on the following button to launch the new currency update application. Try to update the currency several times and you will see either all the records are updated or none of the records is updated. There is no case when only part of the records are updated, even the exceptions are thrown in the middle of the updating loop. The exception is thrown for about half of the updates.

     

    &27425;&12398;&12508;&12479;&12531;&12434;&12463;&12522;&12483;&12463;&12375;&12390;&26032;&12375;&12356;&28858;&26367;&26356;&26032;&12450;&12503;&12522;&12465;&12540;&12471;&12519;&12531;&12434;&36215;&21205;&12375;&12390;&12367;&12384;&12373;&12356;&12290;&28858;&26367;&12398;&26356;&26032;&12434;&25968;&22238;&34892;&12387;&12390;&12415;&12427;&12392;&12289;&12377;&12409;&12390;&12398;&12524;&12467;&12540;&12489;&12364;&26356;&26032;&12373;&12428;&12390;&12356;&12427;&12363;&12289;&12402;&12392;&12388;&12398;&12524;&12467;&12540;&12489;&12418;&26356;&26032;&12373;&12428;&12394;&12356;&12363;&12398;&12289;&12393;&12385;&12425;&12363;&12391;&12354;&12427;&12371;&12392;&12364;&20998;&12363;&12427;&12391;&12375;&12423;&12358;&12290;&12383;&12392;&12360;&26356;&26032;&12523;&12540;&12503;&12398;&36884;&20013;&12391;&20363;&22806;&12364;&25237;&12370;&12425;&12428;&12390;&12418;&12289;&12524;&12467;&12540;&12489;&12398;&19968;&37096;&12384;&12369;&12364;&26356;&26032;&12373;&12428;&12427;&12424;&12358;&12394;&12371;&12392;&12399;&12354;&12426;&12414;&12379;&12435;&12290;&12371;&12398;&20363;&22806;&12399;&21322;&20998;&12411;&12393;&26356;&26032;&12375;&12383;&12392;&12371;&12429;&12391;&25237;&12370;&12425;&12428;&12414;&12377;&12290;

     

    &23436;&20840;&12394;&12477;&12540;&12473;&12467;&12540;&12489;&12398;&12522;&12501;&12449;&12524;&12531;&12473; (Complete source code reference)

    Session bean

     

    &12475;&12483;&12471;&12519;&12531;Bean

     

    • Calculator.java: The session bean interface

     

    &12475;&12483;&12471;&12519;&12531;Bean&12452;&12531;&12479;&12540;&12501;&12455;&12540;&12473;

     

    • TransCalculator.java: The session bean implementation with transactional failure simulations

     

    &12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12398;&22833;&25943;&12434;&12471;&12511;&12517;&12524;&12540;&12488;&12375;&12383;&12475;&12483;&12471;&12519;&12531;Bean&23455;&35013;

     

    • TransException.java: The exception for simulated failure

     

    &12471;&12511;&12517;&12524;&12540;&12488;&12373;&12428;&12383;&22833;&25943;&12434;&34920;&12377;&20363;&22806;

     

    Client

     

    &12463;&12521;&12452;&12450;&12531;&12488;

     

    • update.jsp: The JSP page for the update UI

     

    &26356;&26032;UI&12398;JSP&12506;&12540;&12472;

     

    &12414;&12392;&12417; (Summary)

    The transaction manager is a very important service provided by the EJB 3.0 container. It is declaratively applied to any POJO in the application, but most often, it is applied to session beans. A standard EJB 3.0 transaction is thread-based (i.e., it commits or rolls back at the end of the current thread or method call). In the next trail, we go beyond the thread-based transaction manager and discuss application transactions that span across multiple threads.

     

    &12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12510;&12493;&12540;&12472;&12515;&12399;EJB 3.0&12467;&12531;&12486;&12490;&12395;&12424;&12387;&12390;&25552;&20379;&12373;&12428;&12427;&12392;&12390;&12418;&37325;&35201;&12394;&12469;&12540;&12499;&12473;&12391;&12377;&12290;&12381;&12428;&12399;&12450;&12503;&12522;&12465;&12540;&12471;&12519;&12531;&12398;&12393;&12398;POJO&12395;&12418;&23459;&35328;&30340;&12395;&36969;&29992;&12373;&12428;&12414;&12377;&12364;&12289;&12383;&12356;&12390;&12356;&12399;&12475;&12483;&12471;&12519;&12531;Bean&12395;&36969;&29992;&12373;&12428;&12414;&12377;&12290;&27161;&28310;&30340;&12394;EJB 3.0&12398;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12399;&12473;&12524;&12483;&12489;&12505;&12540;&12473;&12391;&12377;&65288;&12377;&12394;&12431;&12385;&12459;&12524;&12531;&12488;&12473;&12524;&12483;&12489;&12414;&12383;&12399;&12513;&12477;&12483;&12489;&21628;&12403;&20986;&12375;&12398;&26368;&24460;&12395;&12289;&12467;&12511;&12483;&12488;&12414;&12383;&12399;&12525;&12540;&12523;&12496;&12483;&12463;&12375;&12414;&12377;&65289;&12290;&27425;&12398;&23567;&36947;&12391;&12399;&12289;&12473;&12524;&12483;&12489;&12505;&12540;&12473;&12398;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12510;&12493;&12540;&12472;&12515;&12434;&36234;&12360;&12289;&35079;&25968;&12473;&12524;&12483;&12489;&12395;&12414;&12383;&12364;&12427;&12450;&12503;&12522;&12465;&12540;&12471;&12519;&12531;&12488;&12521;&12531;&12470;&12463;&12471;&12519;&12531;&12395;&12388;&12356;&12390;&35542;&12376;&12414;&12377;&12290;

     

    � 2005 JBoss, Inc. All Rights Reserved