summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2008-05-06 16:10:51 +0000
committerBrian S. O'Neill <bronee@gmail.com>2008-05-06 16:10:51 +0000
commit36ad3c8bebb5b216199132b06aab31e1e561fc8c (patch)
treed73bf543baf509d739a851d0fefbfeef6beeaf68 /src/main/java
parentab92f4ec859413b2d3612068dfb21d741fb389a3 (diff)
Preparations for hiding JDBCRepository class.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepositoryBuilder.java2
-rw-r--r--src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorage.java64
2 files changed, 47 insertions, 19 deletions
diff --git a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepositoryBuilder.java b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepositoryBuilder.java
index 0421e28..9996aac 100644
--- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepositoryBuilder.java
+++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepositoryBuilder.java
@@ -79,7 +79,7 @@ public class JDBCRepositoryBuilder extends AbstractRepositoryBuilder {
public JDBCRepositoryBuilder() {
}
- public JDBCRepository build(AtomicReference<Repository> rootRef) throws RepositoryException {
+ public Repository build(AtomicReference<Repository> rootRef) throws RepositoryException {
assertReady();
JDBCRepository repo = new JDBCRepository
(rootRef, getName(), isMaster(), getTriggerFactories(),
diff --git a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorage.java b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorage.java
index d89a291..dd81f90 100644
--- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorage.java
+++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorage.java
@@ -143,7 +143,7 @@ class JDBCStorage<S extends Storable> extends StandardQueryFactory<S>
return;
}
- Connection con = mRepository.getConnection();
+ Connection con = getConnection();
try {
java.sql.Statement st = con.createStatement();
try {
@@ -152,9 +152,9 @@ class JDBCStorage<S extends Storable> extends StandardQueryFactory<S>
st.close();
}
} catch (SQLException e) {
- throw JDBCExceptionTransformer.getInstance().toPersistException(e);
+ throw toPersistException(e);
} finally {
- mRepository.yieldConnection(con);
+ yieldConnection(con);
}
} catch (FetchException e) {
throw e.toPersistException();
@@ -205,6 +205,34 @@ class JDBCStorage<S extends Storable> extends StandardQueryFactory<S>
mTriggerManager.locallyEnableLoad();
}
+ public boolean isTransactionForUpdate() {
+ return mRepository.isTransactionForUpdate();
+ }
+
+ public FetchException toFetchException(Throwable e) {
+ return mRepository.toFetchException(e);
+ }
+
+ public PersistException toPersistException(Throwable e) {
+ return mRepository.toPersistException(e);
+ }
+
+ public boolean isUniqueConstraintError(SQLException e) {
+ return mRepository.isUniqueConstraintError(e);
+ }
+
+ public Connection getConnection() throws FetchException {
+ return mRepository.getConnection();
+ }
+
+ public void yieldConnection(Connection con) throws FetchException {
+ mRepository.yieldConnection(con);
+ }
+
+ public String getDatabaseProductName() {
+ return mRepository.getDatabaseProductName();
+ }
+
/**
* @param loader used to reload Blob outside original transaction
*/
@@ -220,7 +248,7 @@ class JDBCStorage<S extends Storable> extends StandardQueryFactory<S>
txn.register(jblob);
}
} catch (Exception e) {
- throw mRepository.toFetchException(e);
+ throw toFetchException(e);
}
}
@@ -242,7 +270,7 @@ class JDBCStorage<S extends Storable> extends StandardQueryFactory<S>
txn.register(jclob);
}
} catch (Exception e) {
- throw mRepository.toFetchException(e);
+ throw toFetchException(e);
}
}
@@ -334,7 +362,7 @@ class JDBCStorage<S extends Storable> extends StandardQueryFactory<S>
jn = jnb.getRootJoinNode();
jnb.captureOrderings(ordering);
} catch (UndeclaredThrowableException e) {
- throw mRepository.toFetchException(e);
+ throw toFetchException(e);
}
SQLStatementBuilder<S> selectBuilder = new SQLStatementBuilder<S>(mRepository);
@@ -617,7 +645,7 @@ class JDBCStorage<S extends Storable> extends StandardQueryFactory<S>
public Cursor<S> fetch(FilterValues<S> values) throws FetchException {
boolean forUpdate = mRepository.localTransactionScope().isForUpdate();
- Connection con = mRepository.getConnection();
+ Connection con = getConnection();
try {
PreparedStatement ps = con.prepareStatement(prepareSelect(values, forUpdate));
Integer fetchSize = mRepository.getFetchSize();
@@ -640,11 +668,11 @@ class JDBCStorage<S extends Storable> extends StandardQueryFactory<S>
} catch (Exception e) {
// in case of exception, yield connection
try {
- mRepository.yieldConnection(con);
+ yieldConnection(con);
} catch (FetchException e2) {
// ignore and allow triggering exception to propagate
}
- throw mRepository.toFetchException(e);
+ throw toFetchException(e);
}
}
@@ -689,7 +717,7 @@ class JDBCStorage<S extends Storable> extends StandardQueryFactory<S>
select = select.concat(" FOR UPDATE");
}
- Connection con = mRepository.getConnection();
+ Connection con = getConnection();
try {
PreparedStatement ps = con.prepareStatement(select);
Integer fetchSize = mRepository.getFetchSize();
@@ -740,17 +768,17 @@ class JDBCStorage<S extends Storable> extends StandardQueryFactory<S>
} catch (Exception e) {
// in case of exception, yield connection
try {
- mRepository.yieldConnection(con);
+ yieldConnection(con);
} catch (FetchException e2) {
// ignore and allow triggering exception to propagate
}
- throw mRepository.toFetchException(e);
+ throw toFetchException(e);
}
}
@Override
public long count(FilterValues<S> values) throws FetchException {
- Connection con = mRepository.getConnection();
+ Connection con = getConnection();
try {
PreparedStatement ps = con.prepareStatement(prepareCount(values));
try {
@@ -766,9 +794,9 @@ class JDBCStorage<S extends Storable> extends StandardQueryFactory<S>
ps.close();
}
} catch (Exception e) {
- throw mRepository.toFetchException(e);
+ throw toFetchException(e);
} finally {
- mRepository.yieldConnection(con);
+ yieldConnection(con);
}
}
@@ -810,7 +838,7 @@ class JDBCStorage<S extends Storable> extends StandardQueryFactory<S>
int executeDelete(FilterValues<S> filterValues) throws PersistException {
Connection con;
try {
- con = mRepository.getConnection();
+ con = getConnection();
} catch (FetchException e) {
throw e.toPersistException();
}
@@ -823,10 +851,10 @@ class JDBCStorage<S extends Storable> extends StandardQueryFactory<S>
ps.close();
}
} catch (Exception e) {
- throw mRepository.toPersistException(e);
+ throw toPersistException(e);
} finally {
try {
- mRepository.yieldConnection(con);
+ yieldConnection(con);
} catch (FetchException e) {
throw e.toPersistException();
}