1 16 17 package org.springframework.orm.ojb; 18 19 import java.sql.SQLException ; 20 21 import org.apache.ojb.broker.PBKey; 22 import org.apache.ojb.broker.PersistenceBrokerException; 23 import org.apache.ojb.broker.PersistenceBrokerFactory; 24 25 import org.springframework.dao.DataAccessException; 26 import org.springframework.jdbc.support.JdbcAccessor; 27 28 38 public class OjbAccessor extends JdbcAccessor { 39 40 private PBKey pbKey = PersistenceBrokerFactory.getDefaultKey(); 41 42 43 47 public void setJcdAlias(String jcdAlias) { 48 this.pbKey = new PBKey(jcdAlias); 49 } 50 51 55 public String getJcdAlias() { 56 return (this.pbKey != null ? this.pbKey.getAlias() : null); 57 } 58 59 63 public void setPbKey(PBKey pbKey) { 64 this.pbKey = pbKey; 65 } 66 67 70 public PBKey getPbKey() { 71 return pbKey; 72 } 73 74 75 84 public DataAccessException convertOjbAccessException(PersistenceBrokerException ex) { 85 if (ex.getCause() instanceof PersistenceBrokerException) { 86 return convertOjbAccessException((PersistenceBrokerException) ex.getCause()); 87 } 88 else if (ex.getCause() instanceof SQLException ) { 89 return convertJdbcAccessException((SQLException ) ex.getCause()); 90 } 91 else { 92 throw new OjbOperationException(ex); 93 } 94 } 95 96 106 protected DataAccessException convertJdbcAccessException(SQLException ex) { 107 return getExceptionTranslator().translate("OJB operation", null, ex); 108 } 109 110 } 111 | Popular Tags |