1 16 17 package org.springframework.orm.jpa; 18 19 import java.sql.SQLException ; 20 21 import javax.persistence.EntityManager; 22 import javax.persistence.EntityManagerFactory; 23 import javax.persistence.PersistenceException; 24 25 import org.springframework.dao.DataAccessException; 26 import org.springframework.jdbc.datasource.ConnectionHandle; 27 import org.springframework.transaction.InvalidIsolationLevelException; 28 import org.springframework.transaction.TransactionDefinition; 29 import org.springframework.transaction.TransactionException; 30 31 43 public class DefaultJpaDialect implements JpaDialect { 44 45 49 61 public Object beginTransaction(EntityManager entityManager, TransactionDefinition definition) 62 throws PersistenceException, SQLException , TransactionException { 63 64 if (definition.getIsolationLevel() != TransactionDefinition.ISOLATION_DEFAULT) { 65 throw new InvalidIsolationLevelException( 66 "Standard JPA does not support custom isolation levels - " + 67 "use a special JpaDialect for your JPA implementation"); 68 } 69 entityManager.getTransaction().begin(); 70 return null; 71 } 72 73 78 public void cleanupTransaction(Object transactionData) { 79 } 80 81 85 public ConnectionHandle getJdbcConnection(EntityManager entityManager, boolean readOnly) 86 throws PersistenceException, SQLException { 87 88 return null; 89 } 90 91 99 public void releaseJdbcConnection(ConnectionHandle conHandle, EntityManager em) 100 throws PersistenceException, SQLException { 101 } 102 103 104 108 112 public DataAccessException translateExceptionIfPossible(RuntimeException ex) { 113 return EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(ex); 114 } 115 116 117 public boolean supportsEntityManagerFactoryPlusOperations() { 118 return false; 119 } 120 121 public boolean supportsEntityManagerPlusOperations() { 122 return false; 123 } 124 125 public EntityManagerFactoryPlusOperations getEntityManagerFactoryPlusOperations(EntityManagerFactory rawEntityManager) { 126 throw new UnsupportedOperationException (getClass().getName() + " does not support EntityManagerFactoryPlusOperations"); 127 } 128 129 public EntityManagerPlusOperations getEntityManagerPlusOperations(EntityManager rawEntityManager) { 130 throw new UnsupportedOperationException (getClass().getName() + " does not support EntityManagerPlusOperations"); 131 } 132 133 } 134 | Popular Tags |