Changeset 873e52de84747c990bb3a932eb6e9d93db3063f8

Show
Ignore:
Timestamp:
06/09/07 18:54:43 (1 year ago)
Author:
Christopher Jung <bktheg@web.de>
git-committer:
Christopher Jung <bktheg@web.de> 1181408083 +0200
git-parent:

[9db63defa4c6f093cf3eca25f2877d4daa834bb7]

git-author:
Christopher Jung <bktheg@web.de> 1181408083 +0200
Message:

Transaktionsunterstuetzung aus der DB-Klasse entfernt (da jetzt von Hibernate verwaltet)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/net/driftingsouls/ds2/server/framework/db/Database.java

    r948cef9 r873e52d  
    2626import java.sql.Statement; 
    2727 
    28 import net.driftingsouls.ds2.server.framework.Common; 
    2928import net.driftingsouls.ds2.server.framework.Loggable; 
    3029 
     
    4039        private int affectedRows = 0; 
    4140        private int insertid = -1; 
    42         private boolean tStatus = false; 
    4341        private boolean transaction = false; 
    4442        private boolean debugTransaction; 
     
    287285         */ 
    288286        public void tBegin(boolean debugtransact) { 
    289                 if( !transaction ) { 
    290                         transaction = true; 
    291                         tStatus = true; 
    292                         debugTransaction = debugtransact; 
    293                          
    294                  
    295                         try { 
    296                                 connection.setAutoCommit(false); 
    297                         } 
    298                         catch( SQLException e ) { 
    299                                 e.printStackTrace(); 
    300                                 throw new SQLRuntimeException(e); 
    301                         } 
    302                 } 
     287                // EMPTY 
    303288        } 
    304289         
     
    315300         */ 
    316301        public void tUpdate( int count, Object ... query ) { 
    317                 if( !transaction || tStatus ) { 
    318                         update(query); 
    319                         if( transaction && (affectedRows() != count) ) { 
    320                                 tStatus = false; 
    321                                 if( debugTransaction ) { 
    322                                         LOG.warn("Transaktion fehlgeschlagen: "+Common.implode("", query)); 
    323                                 } 
    324                         } 
    325                 } 
    326         } 
    327          
    328         /** 
    329          * Fuehrt ein Rollback auf der aktuellen Transaktion aus 
    330          * 
    331          */ 
    332         public void tRollback() { 
    333                 try { 
    334                         connection.rollback(); 
    335                         connection.setAutoCommit(true); 
    336                 } 
    337                 catch( SQLException e ) { 
    338                         e.printStackTrace(); 
    339                         throw new SQLRuntimeException(e); 
    340                 } 
    341                 transaction = false; 
     302                update(query); 
    342303        } 
    343304         
     
    349310         */ 
    350311        public boolean tCommit() { 
    351                 if( tStatus == true ) { 
    352                         try { 
    353                                 connection.commit(); 
    354                                 connection.setAutoCommit(true); 
    355                         } 
    356                         catch( SQLException e ) { 
    357                                 e.printStackTrace(); 
    358                                 throw new SQLRuntimeException(e); 
    359                         } 
    360                 } 
    361                 else { 
    362                         tRollback();     
    363                 } 
    364                  
    365                 transaction = false; 
    366                  
    367                 return tStatus; 
    368         } 
    369          
    370         /** 
    371          * Liefert die Status der letzten Transaktion zurueck. 
    372          *  
    373          * @return true, falls der Status der letzten Transaktion "ok" war/ist 
    374          */ 
    375         public boolean tStatus() { 
    376                 return tStatus; 
    377         } 
    378          
    379         protected void setTStatus(boolean status) { 
    380                 tStatus = status; 
     312                return true; 
    381313        } 
    382314         
     
    436368        protected void error( String text, Statement stmt ) { 
    437369                error = true; 
    438                 tStatus = false; 
    439370                LOG.error(text); 
    440371                try { 
  • src/net/driftingsouls/ds2/server/framework/db/PreparedQuery.java

    r283e6c7 r873e52d  
    2424import java.sql.SQLException; 
    2525 
    26 import net.driftingsouls.ds2.server.framework.Common; 
    2726import net.driftingsouls.ds2.server.framework.Loggable; 
    2827 
     
    102101         */ 
    103102        public void tUpdate( int count, Object ... values ) { 
    104                 if( !db.isTransaction() || db.tStatus() ) { 
    105                         update(values); 
    106                         if( db.isTransaction() && (affectedRows() != count) ) { 
    107                                 db.setTStatus(false); 
    108                                 if( db.isDebugTransaction() ) { 
    109                                         LOG.warn("Transaktion (PreparedStatement) fehlgeschlagen: "+query+"\nValues: "+Common.implode(" ;; ", values)); 
    110                                 } 
    111                         } 
    112                 } 
     103                update(values); 
    113104        } 
    114105         
  • src/net/driftingsouls/ds2/server/framework/pipeline/generators/DSGenerator.java

    r6d5ded6 r873e52d  
    550550                                                "User: "+(getContext().getActiveUser() != null ? getContext().getActiveUser().getID() : "none")+"\n" + 
    551551                                                "Query-String: "+getContext().getRequest().getQueryString()); 
    552                                 if( getDatabase().isTransaction() ) { 
    553                                         getDatabase().tRollback(); 
    554                                 } 
    555552                        } 
    556553                        catch( NoSuchMethodException e ) { 
     
    564561                                                "User: "+(getContext().getActiveUser() != null ? getContext().getActiveUser().getID() : "none")+"\n" + 
    565562                                                "Query-String: "+getContext().getRequest().getQueryString()); 
    566                                 if( getDatabase().isTransaction() ) { 
    567                                         getDatabase().tRollback(); 
    568                                 } 
    569563                                getContext().getDB().getTransaction().rollback(); 
    570564                        } 
  • src/net/driftingsouls/ds2/server/modules/admin/PlayerDelete.java

    r283e6c7 r873e52d  
    110110                                echo.append(Common.tableEnd()); 
    111111                                 
    112                                 db.tRollback(); 
    113                                  
    114                                 return; 
     112                                context.getDB().getTransaction().rollback(); 
    115113                        } 
    116114                } 
  • web/WEB-INF/cfg/hibernatemappings.xml

    r9db63de r873e52d  
    5858        <mapping class="net.driftingsouls.ds2.server.ships.Ship" /> 
    5959        <mapping class="net.driftingsouls.ds2.server.ships.ShipBaubar" /> 
    60         <!-- ships_lost --
     60        <mapping class="net.driftingsouls.ds2.server.ships.ShipLost" /
    6161        <mapping class="net.driftingsouls.ds2.server.ships.ShipModules" /> 
    6262        <!-- skn -->