1 package org.hibernate; 3 4 import java.io.Serializable ; 5 6 12 public class ConnectionReleaseMode implements Serializable { 13 14 20 public static final ConnectionReleaseMode AFTER_STATEMENT = new ConnectionReleaseMode( "after_statement" ); 21 22 27 public static final ConnectionReleaseMode AFTER_TRANSACTION = new ConnectionReleaseMode( "after_transaction" ); 28 29 33 public static final ConnectionReleaseMode ON_CLOSE = new ConnectionReleaseMode( "on_close" ); 34 35 36 private String name; 37 38 private ConnectionReleaseMode(String name) { 39 this.name = name; 40 } 41 42 public String toString() { 43 return name; 44 } 45 46 public static ConnectionReleaseMode parse(String modeName) { 47 if ( AFTER_STATEMENT.name.equals( modeName ) ) { 48 return AFTER_STATEMENT; 49 } 50 else if ( AFTER_TRANSACTION.name.equals( modeName ) ) { 51 return AFTER_TRANSACTION; 52 } 53 return ON_CLOSE; 55 } 56 57 private Object readResolve() { 58 return parse( name ); 59 } 60 } 61 | Popular Tags |