use of org.seasar.doma.DomaNullPointerException in project doma by domaframework.
the class DaoImplSupportTest method testConstructorParameter1.
@SuppressWarnings("ConstantConditions")
@Test
public void testConstructorParameter1() {
Config config = null;
try {
new DaoImplSupport(config) {
};
fail();
} catch (DomaNullPointerException expected) {
assertEquals("config", expected.getParameterName());
}
}
use of org.seasar.doma.DomaNullPointerException in project doma by domaframework.
the class DaoImplSupportTest method testConstructorParameter3.
@SuppressWarnings("ConstantConditions")
@Test
public void testConstructorParameter3() {
Config config = mock(Config.class);
Connection connection = null;
try {
new DaoImplSupport(config, connection) {
};
fail();
} catch (DomaNullPointerException expected) {
assertEquals("connection", expected.getParameterName());
}
}
use of org.seasar.doma.DomaNullPointerException in project doma by domaframework.
the class BatchUpdateExecutor method execute.
/**
* Executes SQL UPDATE statements.
*
* @param <P> the parameter type
* @param params the parameters
* @param buildConsumer the code block that builds SQL statements
* @return the array whose each element contains affected rows count. The array length is equal to
* the {@code parameter} size.
* @throws DomaNullPointerException if {@code params} or {@code buildConsumer} is {@code null}
* @throws UniqueConstraintException if an unique constraint violation occurs
* @throws JdbcException if a JDBC related error occurs
*/
public <P> int[] execute(Iterable<P> params, BiConsumer<P, BatchBuilder> buildConsumer) {
if (params == null) {
throw new DomaNullPointerException("params");
}
if (buildConsumer == null) {
throw new DomaNullPointerException("buildConsumer");
}
if (query.getMethodName() == null) {
query.setCallerMethodName("execute");
}
BatchBuilder builder = BatchBuilder.newInstance(query);
for (P p : params) {
buildConsumer.accept(p, builder);
builder = builder.fixSql();
}
return builder.execute(() -> new BatchUpdateCommand(query));
}
use of org.seasar.doma.DomaNullPointerException in project doma by domaframework.
the class LocalTransaction method rollback.
/**
* Undoes all changes made after the given save point.
*
* @param savepointName the name of the save point
* @throws DomaNullPointerException if the {@code savepointName} is {@code null}
* @throws SavepointNotFoundException if the save point is not found
* @throws TransactionNotYetBegunException if this transaction is not yet begun
* @throws JdbcException if a JDBC related error occurs
*/
public void rollback(String savepointName) {
if (savepointName == null) {
rollbackInternal("rollback");
throw new DomaNullPointerException("savepointName");
}
LocalTransactionContext context = localTxContextHolder.get();
if (!isActiveInternal(context)) {
throw new TransactionNotYetBegunException(Message.DOMA2062, savepointName);
}
String id = context.getId();
Savepoint savepoint = context.getSavepoint(savepointName);
if (savepoint == null) {
rollbackInternal("rollback");
throw new SavepointNotFoundException(savepointName);
}
LocalTransactionConnection connection = context.getConnection();
try {
connection.rollback(savepoint);
} catch (SQLException e) {
rollbackInternal("rollback");
throw new JdbcException(Message.DOMA2052, e, savepointName, e);
}
jdbcLogger.logTransactionSavepointRolledback(className, "rollback", id, savepointName);
}
use of org.seasar.doma.DomaNullPointerException in project doma by domaframework.
the class LocalTransaction method setSavepoint.
/**
* Creates a save point with the specified name.
*
* @param savepointName the name of the save point
* @throws DomaNullPointerException if the {@code savepointName} is {@code null}
* @throws TransactionNotYetBegunException if this transaction is not yet begun
* @throws SavepointAlreadyExistsException if the save point already exists
* @throws JdbcException if a JDBC related error occurs
*/
public void setSavepoint(String savepointName) {
if (savepointName == null) {
rollbackInternal("setSavepoint");
throw new DomaNullPointerException("savepointName");
}
LocalTransactionContext context = localTxContextHolder.get();
if (!isActiveInternal(context)) {
throw new TransactionNotYetBegunException(Message.DOMA2053, savepointName);
}
String id = context.getId();
Savepoint savepoint = context.getSavepoint(savepointName);
if (savepoint != null) {
rollbackInternal("setSavepoint");
throw new SavepointAlreadyExistsException(savepointName);
}
LocalTransactionConnection connection = context.getConnection();
try {
savepoint = connection.setSavepoint(savepointName);
} catch (SQLException e) {
rollbackInternal("setSavepoint");
throw new JdbcException(Message.DOMA2051, e, savepointName, e);
}
context.addSavepoint(savepointName, savepoint);
jdbcLogger.logTransactionSavepointCreated(className, "setSavepoint", id, savepointName);
}
Aggregations